From c2a1c4e8e3b37f971ca076d629bfa10edbd48746 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 22 Sep 2025 15:26:13 +0100 Subject: [PATCH 1/2] gh-136744: Remove unnecessary chmod from pydoc.apropos() test. (GH-136746) Remove unnecessary chmod from pydoc.apropos() test. (cherry picked from commit 04c4628345b841ae9792ea007d7beffd2846f017) Co-authored-by: Russell Keith-Magee --- Lib/test/test_pydoc/test_pydoc.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Lib/test/test_pydoc/test_pydoc.py b/Lib/test/test_pydoc/test_pydoc.py index 7623930affe4fc..13a19f3c2fbad6 100644 --- a/Lib/test/test_pydoc/test_pydoc.py +++ b/Lib/test/test_pydoc/test_pydoc.py @@ -11,7 +11,6 @@ import _pickle import pkgutil import re -import stat import tempfile import test.support import time @@ -1303,24 +1302,14 @@ def test_apropos_with_unreadable_dir(self): @os_helper.skip_unless_working_chmod def test_apropos_empty_doc(self): pkgdir = os.path.join(TESTFN, 'walkpkg') - if support.is_emscripten: - # Emscripten's readdir implementation is buggy on directories - # with read permission but no execute permission. - old_umask = os.umask(0) - self.addCleanup(os.umask, old_umask) os.mkdir(pkgdir) self.addCleanup(rmtree, pkgdir) init_path = os.path.join(pkgdir, '__init__.py') with open(init_path, 'w') as fobj: fobj.write("foo = 1") - current_mode = stat.S_IMODE(os.stat(pkgdir).st_mode) - try: - os.chmod(pkgdir, current_mode & ~stat.S_IEXEC) - with self.restrict_walk_packages(path=[TESTFN]), captured_stdout() as stdout: - pydoc.apropos('') - self.assertIn('walkpkg', stdout.getvalue()) - finally: - os.chmod(pkgdir, current_mode) + with self.restrict_walk_packages(path=[TESTFN]), captured_stdout() as stdout: + pydoc.apropos('') + self.assertIn('walkpkg', stdout.getvalue()) def test_url_search_package_error(self): # URL handler search should cope with packages that raise exceptions From fcd62b50c913441b30c6d9481eeadbaca981e67a Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 23 Sep 2025 16:33:50 +0100 Subject: [PATCH 2/2] Backport cleanup from GH-139267 Co-authored-by: Zachary Ware --- Lib/test/test_pydoc/test_pydoc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/test_pydoc/test_pydoc.py b/Lib/test/test_pydoc/test_pydoc.py index 13a19f3c2fbad6..953cfe69f87cb8 100644 --- a/Lib/test/test_pydoc/test_pydoc.py +++ b/Lib/test/test_pydoc/test_pydoc.py @@ -1299,7 +1299,6 @@ def test_apropos_with_unreadable_dir(self): self.assertEqual(out.getvalue(), '') self.assertEqual(err.getvalue(), '') - @os_helper.skip_unless_working_chmod def test_apropos_empty_doc(self): pkgdir = os.path.join(TESTFN, 'walkpkg') os.mkdir(pkgdir)