Skip to content

gh-149083: Use sentinel for os.path.{ALLOW_MISSING,ALL_BUT_LAST}#149613

Open
JelleZijlstra wants to merge 2 commits intopython:mainfrom
JelleZijlstra:main
Open

gh-149083: Use sentinel for os.path.{ALLOW_MISSING,ALL_BUT_LAST}#149613
JelleZijlstra wants to merge 2 commits intopython:mainfrom
JelleZijlstra:main

Conversation

@JelleZijlstra
Copy link
Copy Markdown
Member

@JelleZijlstra JelleZijlstra commented May 9, 2026

ALL_BUT_LAST is new in 3.15 (#117562). ALLOW_MISSING is also recent (#135037) but was backported to other branches for security reasons.

Making these sentinels has a few effects:

  • The repr changes from os.path.ALLOW_MISSING to just ALLOW_MISSING
  • The docstring is no longer present on the object itself.

Still it seems worth it to simplify to standard sentinels for 3.15+.

@JelleZijlstra JelleZijlstra added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label May 9, 2026
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 9, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32618158 | 📁 Comparing 71b5fee against main (7241f27)

  🔍 Preview build  

2 files changed
± library/os.path.html
± whatsnew/changelog.html

Comment thread Lib/genericpath.py
return self.__class__.__name__
# Sentinels.
ALL_BUT_LAST = sentinel('ALL_BUT_LAST')
"""Special value for use in realpath()."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it used as a docstring of the sentinel? I wonder, how can this be implemented?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sentinels don't actually support docstrings. Putting a string like this is an established way to document a variable and I believe Sphinx supports it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then they are not needed.

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

Labels

awaiting core review needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants