Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pydoc test_apropos_empty_doc test performs questionable chmod #136744

Open
Labels
testsTests in the Lib/test dirtype-refactorCode refactoring (with no changes in behavior)
@freakboy3742

Description

@freakboy3742

The test for empty strings in calls topydoc.apropos() uses a chmod call that seems non-sensical:

@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).

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-refactorCode refactoring (with no changes in behavior)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp