Skip to content

gh-86533: Restore os.makedirs() ability to apply *mode* recursively#150011

Open
nessita wants to merge 13 commits into
python:mainfrom
nessita:pr/23901
Open

gh-86533: Restore os.makedirs() ability to apply *mode* recursively#150011
nessita wants to merge 13 commits into
python:mainfrom
nessita:pr/23901

Conversation

@nessita
Copy link
Copy Markdown

@nessita nessita commented May 18, 2026

ZackerySpytz and others added 13 commits December 22, 2020 16:56
Allow os.makedirs() to apply the *mode* argument to any intermediate
directories that are created.
- 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 <noreply@anthropic.com>
- 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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented May 18, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@nessita
Copy link
Copy Markdown
Author

nessita commented May 18, 2026

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

@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32743236 | 📁 Comparing 73cc9eb against main (dbd8985)

  🔍 Preview build  

4 files changed
± library/os.html
± library/pathlib.html
± whatsnew/3.15.html
± whatsnew/changelog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants