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 — gh-86533: Restore os.makedirs() ability to apply *mode* recursively by nessita · Pull Request #150011 · python/cpython

Conversation

@nessita

@nessita nessita commented May 18, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: Restore os.makedirs ability to apply mode to all directories created #86533

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ZackerySpytz and others added 13 commits December 22, 2020 16:56
@ZackerySpytz
bpo-42367: Restore os.makedirs() ability to apply *mode* recursively
128ff8b
Allow os.makedirs() to apply the *mode* argument to any intermediate
directories that are created.
@erlend-aasland
Sync with main
109bd57
@gpshead
Merge main into pr-23901
710665a
@gpshead @claude
Modernize os.makedirs for Python 3.15: Add parent_mode parameter
04a73cd
- Replace recursive_mode with more intuitive parent_mode parameter
- parent_mode=None (default): intermediate dirs use default permissions
- parent_mode=<mode>: intermediate dirs use specified permissions
- parent_mode=mode: matches Python 3.6 behavior
- Update documentation with version markers and usage examples
- Add comprehensive test coverage with separate focused test functions
- Fix test permissions to avoid cleanup issues (0o555 → 0o705)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@gpshead @claude
Add parent_mode parameter to pathlib.Path.mkdir
67ae3af
- Add parent_mode parameter to Path.mkdir() for specifying intermediate
  directory permissions when parents=True
- Maintain pathlib's independence by using recursive implementation
  rather than delegating to os.makedirs
- Add comprehensive tests including umask behavior verification
- Update documentation and whatsnew entries
- Provides consistency with os.makedirs parent_mode parameter

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@gpshead
merge the NEWS entries
0a8c61e
@gpshead @claude
Fix pathlib parent_mode tests for Android filesystem compatibility
9371670
Use st_mode & 0o777 masking instead of stat.S_IMODE() to ignore
filesystem-specific bits like setgid, matching the approach used
in os.makedirs tests.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@gpshead
add test skips for WASI and android where file modes don't work well …
988d1c4
…enough
@gpshead
doc line length
ccce063
@gpshead @ZackerySpytz
add comma to docs
bdf5c8c
Co-authored-by: Zackery Spytz <[email protected]>
@gpshead @ZackerySpytz
add comma to docs
de7139c
Co-authored-by: Zackery Spytz <[email protected]>
@gpshead
line length
59c982f
@nessita
Merge branch 'main' into pr/23901
73cc9eb
@nessita
nessita requested review from AA-Turner and barneygale as code owners May 18, 2026 18:12
@python-cla-bot

python-cla-bot Bot commented May 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot mentioned this pull request May 18, 2026
Restore os.makedirs ability to apply mode to all directories created #86533
Closed
@bedevere-app bedevere-app Bot added the awaiting review label May 18, 2026
@nessita

nessita commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

@gpshead Hi! This is the PR we talked abut with the conflict fixed.

gpshead reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gpshead gpshead mentioned this pull request May 18, 2026
gh-86533: Restore os.makedirs() ability to apply *mode* recursively #23901
Closed
@read-the-docs-community

read-the-docs-community Bot commented May 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32747194 | 📁 Comparing 6870753 against main (dbd8985)

  🔍 Preview build  

7 files changed · + 1 added · ± 6 modified

+ Added

  • deprecations/pending-removal-in-3.21.html

± Modified

  • deprecations/index.html
  • library/os.html
  • library/pathlib.html
  • whatsnew/3.15.html
  • whatsnew/3.16.html
  • whatsnew/changelog.html
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gpshead gpshead self-assigned this May 18, 2026
@gpshead gpshead added the sprint label May 18, 2026
@github-project-automation github-project-automation Bot added this to Sprint May 18, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Sprint May 18, 2026
@gpshead
pythongh-86533: Clarify parent_mode umask docs and harden makedirs/mk…
6870753
…dir tests

Address review feedback on the parent_mode addition:

- Docs (os.makedirs, Path.mkdir): state that parent_mode, like mode, is
  combined with the process umask; it does not bypass it.
- Mark the parameter as added in 3.15 (approved for the 3.15 backport)
  instead of "next", which on main would resolve to 3.16.
- Replace the misleading "parent_mode overrides umask" test with one
  that verifies umask IS applied to parent_mode (0o777 + umask 0o022 ->
  0o755); add the matching os.makedirs test.
- Make MakedirTests cleanup name-agnostic and robust via
  os_helper.rmtree() instead of a hard-coded dir1/.../dir6 walk.
- Align the new test_os skips with the pathlib tests
  (Emscripten/WASI/Android); restore the original 0o555 case in
  test_mode.
- Use os_helper.temp_umask() in the pathlib tests instead of a manual
  os.umask() try/finally.
@gpshead gpshead added needs backport to 3.15 bugs and security fixes type-feature A feature request or enhancement type-security A security issue type-bug An unexpected behavior, bug, or error labels May 18, 2026
@gpshead gpshead added awaiting merge and removed awaiting review labels May 18, 2026
gpshead
gpshead approved these changes May 18, 2026
View reviewed changes
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Sprint May 18, 2026
@gpshead
gpshead enabled auto-merge (squash) May 18, 2026 22:49
@gpshead
gpshead merged commit 9770e32 into python:main May 18, 2026
61 of 64 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-project-automation github-project-automation Bot moved this from In Progress to Done in Sprint May 18, 2026
@bedevere-app bedevere-app Bot removed the awaiting merge label May 18, 2026
@miss-islington-app

miss-islington-app Bot commented May 18, 2026

Copy link
Copy Markdown

Thanks @nessita for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

nessita reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app

bedevere-app Bot commented May 18, 2026

Copy link
Copy Markdown

GH-150036 is a backport of this pull request to the 3.15 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label May 18, 2026
@nessita
nessita deleted the pr/23901 branch May 18, 2026 23:03
@bedevere-bot

bedevere-bot commented May 18, 2026

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 CentOS9 NoGIL 3.x (tier-1) has failed when building commit 9770e32.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1609/builds/5752) and take a look at the build logs.
  4. Check if the failure is related to this commit (9770e32) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1609/builds/5752

Failed tests:

  • test_pathlib

Failed subtests:

  • test_mkdir_with_parent_mode - test.test_pathlib.test_pathlib.PathSubclassTest.test_mkdir_with_parent_mode
  • test_mkdir_parent_mode_deep_hierarchy - test.test_pathlib.test_pathlib.PathSubclassTest.test_mkdir_parent_mode_deep_hierarchy
  • test_mkdir_parent_mode_same_as_mode - test.test_pathlib.test_pathlib.PosixPathTest.test_mkdir_parent_mode_same_as_mode
  • test_mkdir_parent_mode_same_as_mode - test.test_pathlib.test_pathlib.PathTest.test_mkdir_parent_mode_same_as_mode
  • test_mkdir_parent_mode_deep_hierarchy - test.test_pathlib.test_pathlib.PathTest.test_mkdir_parent_mode_deep_hierarchy
  • test_mkdir_parent_mode_deep_hierarchy - test.test_pathlib.test_pathlib.PosixPathTest.test_mkdir_parent_mode_deep_hierarchy
  • test_mkdir_parent_mode_same_as_mode - test.test_pathlib.test_pathlib.PathSubclassTest.test_mkdir_parent_mode_same_as_mode
  • test_mkdir_with_parent_mode - test.test_pathlib.test_pathlib.PathTest.test_mkdir_with_parent_mode
  • test_mkdir_with_parent_mode - test.test_pathlib.test_pathlib.PosixPathTest.test_mkdir_with_parent_mode

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.itamaro-centos-aws.nogil/build/Lib/test/test_pathlib/test_pathlib.py", line 2534, in test_mkdir_with_parent_mode
    self.assertEqual(p.stat().st_mode & 0o777, 0o755)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 448 != 493


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.itamaro-centos-aws.nogil/build/Lib/test/test_pathlib/test_pathlib.py", line 2559, in test_mkdir_parent_mode_deep_hierarchy
    self.assertEqual(p.stat().st_mode & 0o777, 0o755)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 448 != 493


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.itamaro-centos-aws.nogil/build/Lib/test/test_pathlib/test_pathlib.py", line 2599, in test_mkdir_parent_mode_same_as_mode
    self.assertEqual(p.stat().st_mode & 0o777, 0o705)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 448 != 453
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented May 18, 2026

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARM Raspbian 3.x (tier-3) has failed when building commit 9770e32.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/424/builds/13744) and take a look at the build logs.
  4. Check if the failure is related to this commit (9770e32) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/424/builds/13744

Failed tests:

  • test_pathlib

Failed subtests:

  • test_mkdir_with_parent_mode - test.test_pathlib.test_pathlib.PathSubclassTest.test_mkdir_with_parent_mode
  • test_mkdir_parent_mode_deep_hierarchy - test.test_pathlib.test_pathlib.PathSubclassTest.test_mkdir_parent_mode_deep_hierarchy
  • test_mkdir_parent_mode_same_as_mode - test.test_pathlib.test_pathlib.PosixPathTest.test_mkdir_parent_mode_same_as_mode
  • test_mkdir_parent_mode_same_as_mode - test.test_pathlib.test_pathlib.PathTest.test_mkdir_parent_mode_same_as_mode
  • test_mkdir_parent_mode_deep_hierarchy - test.test_pathlib.test_pathlib.PathTest.test_mkdir_parent_mode_deep_hierarchy
  • test_mkdir_parent_mode_deep_hierarchy - test.test_pathlib.test_pathlib.PosixPathTest.test_mkdir_parent_mode_deep_hierarchy
  • test_mkdir_parent_mode_same_as_mode - test.test_pathlib.test_pathlib.PathSubclassTest.test_mkdir_parent_mode_same_as_mode
  • test_mkdir_with_parent_mode - test.test_pathlib.test_pathlib.PathTest.test_mkdir_with_parent_mode
  • test_mkdir_with_parent_mode - test.test_pathlib.test_pathlib.PosixPathTest.test_mkdir_with_parent_mode

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/var/lib/buildbot/workers/3.x.gps-raspbian.nondebug/build/Lib/test/test_pathlib/test_pathlib.py", line 2599, in test_mkdir_parent_mode_same_as_mode
    self.assertEqual(p.stat().st_mode & 0o777, 0o705)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 448 != 453


Traceback (most recent call last):
  File "/var/lib/buildbot/workers/3.x.gps-raspbian.nondebug/build/Lib/test/test_pathlib/test_pathlib.py", line 2534, in test_mkdir_with_parent_mode
    self.assertEqual(p.stat().st_mode & 0o777, 0o755)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 448 != 493


Traceback (most recent call last):
  File "/var/lib/buildbot/workers/3.x.gps-raspbian.nondebug/build/Lib/test/test_pathlib/test_pathlib.py", line 2559, in test_mkdir_parent_mode_deep_hierarchy
    self.assertEqual(p.stat().st_mode & 0o777, 0o755)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 448 != 493
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented May 18, 2026

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARM64 MacOS M1 NoGIL 3.x (tier-2) has failed when building commit 9770e32.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1270/builds/7602) and take a look at the build logs.
  4. Check if the failure is related to this commit (9770e32) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1270/builds/7602

Failed tests:

  • test_pathlib

Failed subtests:

  • test_mkdir_with_parent_mode - test.test_pathlib.test_pathlib.PathSubclassTest.test_mkdir_with_parent_mode
  • test_mkdir_parent_mode_deep_hierarchy - test.test_pathlib.test_pathlib.PathSubclassTest.test_mkdir_parent_mode_deep_hierarchy
  • test_mkdir_parent_mode_same_as_mode - test.test_pathlib.test_pathlib.PosixPathTest.test_mkdir_parent_mode_same_as_mode
  • test_mkdir_parent_mode_same_as_mode - test.test_pathlib.test_pathlib.PathTest.test_mkdir_parent_mode_same_as_mode
  • test_mkdir_parent_mode_deep_hierarchy - test.test_pathlib.test_pathlib.PathTest.test_mkdir_parent_mode_deep_hierarchy
  • test_mkdir_parent_mode_deep_hierarchy - test.test_pathlib.test_pathlib.PosixPathTest.test_mkdir_parent_mode_deep_hierarchy
  • test_mkdir_parent_mode_same_as_mode - test.test_pathlib.test_pathlib.PathSubclassTest.test_mkdir_parent_mode_same_as_mode
  • test_mkdir_with_parent_mode - test.test_pathlib.test_pathlib.PathTest.test_mkdir_with_parent_mode
  • test_mkdir_with_parent_mode - test.test_pathlib.test_pathlib.PosixPathTest.test_mkdir_with_parent_mode

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/test_pathlib/test_pathlib.py", line 2559, in test_mkdir_parent_mode_deep_hierarchy
    self.assertEqual(p.stat().st_mode & 0o777, 0o755)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 448 != 493


Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/test_pathlib/test_pathlib.py", line 2534, in test_mkdir_with_parent_mode
    self.assertEqual(p.stat().st_mode & 0o777, 0o755)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 448 != 493


Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.itamaro-macos-arm64-aws.macos-with-brew.nogil/build/Lib/test/test_pathlib/test_pathlib.py", line 2599, in test_mkdir_parent_mode_same_as_mode
    self.assertEqual(p.stat().st_mode & 0o777, 0o705)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 448 != 453
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gpshead gpshead mentioned this pull request May 18, 2026
gh-86533: Make Path.mkdir parent_mode tests umask-independent #150040
Merged
gpshead added a commit that referenced this pull request May 19, 2026
@miss-islington @nessita
@ZackerySpytz @erlend-aasland @gpshead
[3.15] gh-86533: Restore os.makedirs() ability to apply *mode* recurs…
28f275f
…ively (GH-150011) (#150036)

bpo-42367: Restore os.makedirs() and pathlib.mkdir() ability to apply *mode* recursively via a new parent_mode= keyword argument.
(cherry picked from commit 9770e32)

+ Make Path.mkdir parent_mode tests umask-independent

test_mkdir_with_parent_mode, test_mkdir_parent_mode_deep_hierarchy and
test_mkdir_parent_mode_same_as_mode assert exact directory mode bits but
did not pin the process umask.  On buildbots running with a restrictive
umask (e.g. 0o077) the 0o755 leaf was masked down to 0o700, failing the
assertions.  Wrap them in os_helper.temp_umask(0o022), matching the
other umask-aware mkdir tests in this file.

---------

Co-authored-by: nessita <[email protected]>
Co-authored-by: Zackery Spytz <[email protected]>
Co-authored-by: Erlend E. Aasland <[email protected]>
Co-authored-by: Gregory P. Smith <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gpshead gpshead gpshead approved these changes
@barneygale barneygale Awaiting requested review from barneygale barneygale is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gpshead gpshead

Labels

sprint type-bug An unexpected behavior, bug, or error type-feature A feature request or enhancement type-security A security issue

Projects

Sprint
Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@nessita @bedevere-bot @gpshead @ZackerySpytz @erlend-aasland
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — 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.