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 ZackerySpytz · Pull Request #23901 · python/cpython

Conversation

@ZackerySpytz

@ZackerySpytz ZackerySpytz commented Dec 22, 2020 •
edited by gpshead
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Allow os.makedirs() to set the mode of intermediate directories that are created. This adds a parent_mode argument to allow explicitly setting those modes instead of inheriting from the
umask.

Also adds the equivalent feature to pathlib.Path.mkdir for consistency as noted in the issue.

https://bugs.python.org/issue42367

  • 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
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.
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Dec 22, 2020
@bedevere-bot bedevere-bot added the awaiting review label Dec 22, 2020
@github-actions

github-actions Bot commented Jan 22, 2021

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Jan 22, 2021
@ZackerySpytz

ZackerySpytz commented Jan 22, 2021

Copy link
Copy Markdown
Contributor Author

It is not stale.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Jan 23, 2021
@github-actions

github-actions Bot commented Feb 23, 2021

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Feb 23, 2021
@chimosky

chimosky commented Jul 8, 2021

Copy link
Copy Markdown

@ZackerySpytz is there any workaround for this at the moment as you stated in #42367 that umask can't be used to control the intermediate directory creation permissions.

All reactions

Sorry, something went wrong.

Uh oh!

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

@chimosky chimosky mentioned this pull request Jul 9, 2021
PermissionError when trying to install an activity. sugarlabs/sugar#946
Closed
MaxwellDupre

This comment was marked as outdated.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot added awaiting core review and removed awaiting review labels Feb 12, 2022
@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 2, 2022
@gpshead gpshead mentioned this pull request Jan 5, 2024
Restore os.makedirs ability to apply mode to all directories created #86533
Closed
@erlend-aasland erlend-aasland changed the title bpo-42367: Restore os.makedirs() ability to apply *mode* recursively gh-86533: Restore os.makedirs() ability to apply *mode* recursively Jan 5, 2024
@erlend-aasland
Sync with main
109bd57
@vanschelven vanschelven mentioned this pull request Aug 29, 2025
os.makedirs('dir1/dir2', 0) always fails #64129
Closed
vanschelven added a commit to bugsink/bugsink that referenced this pull request Aug 29, 2025
@vanschelven
Hardening of Temporary-Directory Usage
f20b583
Defends against certain forms of local privilege escalation, i.e.
understood to be defense in depth rather than a security issue given
the recommended ways of deploying (docker container or in a single-use
single-server)

Fix #174

See python/cpython#23901
gpshead and others added 2 commits August 30, 2025 06:39
@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
gpshead requested review from AA-Turner and barneygale as code owners August 30, 2025 07:33
@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
gpshead force-pushed the bpo-42367-makedirs-dir-mode branch from 3cc6495 to 67ae3af Compare August 30, 2025 08:06
@gpshead
merge the NEWS entries
0a8c61e
@gpshead gpshead self-assigned this Aug 30, 2025
@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]>
vanschelven added a commit to bugsink/bugsink that referenced this pull request Aug 30, 2025
@vanschelven
Hardening of Temporary-Directory Usage
4ad3c5e
Defends against certain forms of local privilege escalation, i.e.
understood to be defense in depth rather than a security issue given
the recommended ways of deploying (docker container or in a single-use
single-server)

Fix #174

See python/cpython#23901
ZackerySpytz
ZackerySpytz commented Aug 30, 2025
View reviewed changes

@ZackerySpytz ZackerySpytz left a comment

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, @gpshead. I see that you have made some changes to this PR. I have pointed out some lines in the changes you have made that we should modify.

We should also make sure that the lines in the new pathlib code are limited to a maximum of 79 characters (for PEP 8 compliance).

Sorry, something went wrong.

Uh oh!

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

gpshead reacted with heart emoji
All reactions
  • ❤️ 1 reaction
Comment thread Doc/library/os.rst Resolved

Uh oh!

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

Comment thread Doc/library/pathlib.rst Resolved

Uh oh!

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

Comment thread Doc/library/pathlib.rst Resolved

Uh oh!

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

gpshead and others added 5 commits August 31, 2025 01:20
@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
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 8, 2026
@gpshead

gpshead commented May 18, 2026

Copy link
Copy Markdown
Member

replaced by #150011

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.

@gpshead gpshead closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@barneygale barneygale Awaiting requested review from barneygale barneygale is a code owner
1 more reviewer
@MaxwellDupre MaxwellDupre MaxwellDupre requested changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

@gpshead gpshead

Labels

awaiting core review stale Stale PR or inactive for long period of time.

Projects

None yet

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.

8 participants

@ZackerySpytz @chimosky @gpshead @MaxwellDupre @the-knights-who-say-ni @ezio-melotti @bedevere-bot @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.