GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pydoc test_apropos_empty_doc test performs questionable chmod · Issue #136744 · python/cpython

pydoc test_apropos_empty_doc test performs questionable chmod #136744

New issue
Copy link
New issue
Copy link
Closed
Closed
pydoc test_apropos_empty_doc test performs questionable chmod#136744
Copy link
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtestsTests in the Lib/test dirTests in the Lib/test dirtype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

Description

@freakboy3742
freakboy3742
opened on Jul 17, 2025
Issue body actions

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

cpython/Lib/test/test_pydoc/test_pydoc.py

Lines 1303 to 1318 in 7ec1fab

@os_helper.skip_unless_working_chmod
def test_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')
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)

(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, it can'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 removes user execute permissions. Group and Global execute permissions are retained. The original report removed all 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 permissions is effectively equivalent to chmod 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

  • gh-136744: Remove unnecessary chmod from pydoc.apropos() test. #136746
  • [3.14] gh-136744: Remove unnecessary chmod from pydoc.apropos() test. (GH-136746) #139242
  • gh-136744: Remove a redundant test skip #139267
  • [3.14] gh-136744: Remove a redundant test skip (GH-139267) #139268

Activity

  1. freakboy3742
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Jul 17, 2025
  2. StanFromIreland
    added
    type-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)
    on Jul 17, 2025
  3. ambv
    added a commit that references this issue on Sep 22, 2025

    gh-136744: Remove unnecessary chmod from pydoc.apropos() test. (GH-13…

    04c4628
  4. miss-islington
    added a commit that references this issue on Sep 22, 2025

    pythongh-136744: Remove unnecessary chmod from pydoc.apropos() test. (p…

    c2a1c4e
  5. freakboy3742
    added a commit that references this issue on Sep 23, 2025

    gh-136744: Remove a redundant test skip (#139267)

    a79ce35
  6. miss-islington
    added a commit that references this issue on Sep 23, 2025

    pythongh-136744: Remove a redundant test skip (pythonGH-139267)

    c3aab81
  7. hugovk
    added a commit that references this issue on Sep 29, 2025

    [3.14] gh-136744: Remove unnecessary chmod from pydoc.apropos() test. (…

    997e471
  8. StanFromIreland commented on Oct 3, 2025

    @StanFromIreland
    StanFromIreland
    on Oct 3, 2025
    Member
    More actions

    Triage: Is there anything left to do here?

  9. StanFromIreland
    added
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Oct 3, 2025
  10. freakboy3742 commented on Oct 5, 2025

    @freakboy3742
    freakboy3742
    on Oct 5, 2025
    ContributorAuthor
    More actions

    I think this is all resolved; we were only waiting on the 3.14 backport.

  11. freakboy3742
    closed this as completedon Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtestsTests in the Lib/test dirTests in the Lib/test dirtype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.