Skip to content

umasked os.makedirs() sometimes fails on Emscripten #135783

Closed

Description

@freakboy3742

Bug report

Bug description:

When os.umask is used on a os.makedirs() call, the permissions aren't always honoured:

os.umask(0o002)
os.makedirs("./dir1/dir2")
print(os.stat("./dir1").st_mode & 0o777)

Should return 0o775; but returns 0o755 on some installs.

This can be observed as a failure of test_os.MakedirTests.test_mode. The Emscripten buildbot fails consistently on this; it also fails on my macOS machine. However, @hoodmane has been unable to reproduce it. The test has been skipped as part of #127146 to get a passing buildbot; more investigation is required.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    3.14bugs and security fixes
    3.15bugs and security fixes
    on Jun 21, 2025
  2. self-assigned this
    on Jun 21, 2025
  3. added a commit that references this issue on Jun 21, 2025
  4. added a commit that references this issue on Jun 21, 2025
  5. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Jun 21, 2025
  6. added a commit that references this issue on Jun 21, 2025
  7. added a commit that references this issue on Jul 12, 2025
  8. freakboy3742 commented on Jul 16, 2025

    @freakboy3742
    ContributorAuthor

    Pairing with @hoodmane at Europython - we've found the cause. Emscripten's umask function appears to be a no-op; on @hoodmane machine, the default umask is the same as the one used in the test, so the test passes. On the test machine and my machine, the default umask is 0o022, so the no-op umask is a problem.

    This strictly means the test is a little fragile, as it will always pass if the host machine where the test is executing has a umask of 0o002.

  9. added a commit that references this issue on Aug 4, 2025
  10. added a commit that references this issue on Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.14bugs and security fixes3.15bugs and security fixesOS-emscriptenstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions