Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
Description
The test for empty strings in calls topydoc.apropos()
uses a chmod call that seems non-sensical:
cpython/Lib/test/test_pydoc/test_pydoc.py
Lines 1303 to 1318 in7ec1fab
@os_helper.skip_unless_working_chmod | |
deftest_apropos_empty_doc(self): | |
pkgdir=os.path.join(TESTFN,'walkpkg') | |
os.mkdir(pkgdir) | |
self.addCleanup(rmtree,pkgdir) | |
init_path=os.path.join(pkgdir,'__init__.py') | |
withopen(init_path,'w')asfobj: | |
fobj.write("foo = 1") | |
current_mode=stat.S_IMODE(os.stat(pkgdir).st_mode) | |
try: | |
os.chmod(pkgdir,current_mode&~stat.S_IEXEC) | |
withself.restrict_walk_packages(path=[TESTFN]),captured_stdout()asstdout: | |
pydoc.apropos('') | |
self.assertIn('walkpkg',stdout.getvalue()) | |
finally: | |
os.chmod(pkgdir,current_mode) |
(Line 1313 in particular)
This test was added as part of resolving#65747. Part of the triage of that issue included the observation that the problem could be reproduced by removing execute permissions from a directory. However, this appears to be unrelated to the reported problem.
By removing the x permission from the directory, the module is converted into a namespace package - at which point, itcan't have a docstring. However, you can also validate this by... having a module without a docstring. Which the current test implements.
Adding to the confusion - the test only removesuser execute permissions. Group and Global execute permissions are retained. The original report removedall execute permissions, not just user execute permissions; so the test isn't reproducing the triage example. The only explanation I can find for this is that the buildbots run with a umask of 0o77, which means removing user execute permissionsis effectively equivalent tochmod a-x
... but it won't be for anyone who isn't running under buildbot.
This was discovered in the process of developing#136740. This did reveal a bug in Emscripten's implementation of readdir() - but the actual test itself doesn't make any sense to me (or@hoodmane).