FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-149083: Make functools.Placeholder a sentinel by JelleZijlstra · Pull Request #149088 · python/cpython · GitHub

/ cpython Public

gh-149083: Make functools.Placeholder a sentinel - #149088

Open
JelleZijlstra wants to merge 1 commit into
python:mainfrom
JelleZijlstra:placehold
Open

gh-149083: Make functools.Placeholder a sentinel#149088
JelleZijlstra wants to merge 1 commit into
python:mainfrom
JelleZijlstra:placehold

Conversation

JelleZijlstra commented Apr 28, 2026
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

This greatly simplifies the code. The only behavioral difference observable in the tests is that type(Placeholder)() no longer works, because Placeholder is now an instance of sentinel.


📚 Documentation preview 📚: https://cpython-previews--149088.org.readthedocs.build/

picnixz commented Apr 28, 2026
edited
Loading

Copy link
Copy Markdown
Member

Is type(Placeholder)() acceptable? I would have actually expected that type(MySentinel)() returned the sentinel as for type(None)() but it's not the case since MySentinel is an instance of a sentinel!

picnixz commented Apr 28, 2026

Copy link
Copy Markdown
Member

Actually, since we're launching beta, it may be ok to change this and see if it breaks something

Copy link
Copy Markdown
Member Author

It's difficult to imagine why people would be doing things like type(Placeholder)() outside of test code, but you never know.

picnixz commented Apr 28, 2026

Copy link
Copy Markdown
Member

I can see people doing type(Placeholder) for maybe their mypy plugin or whatever, or even for checking if a default is a placeholder instance and do something else with it (though they should assume that it's a singleton so there is no real need to check placeholders through isinstance checks). I think there was a discussion when introducing placeholders about type(P)() returning P but I can't find it (and maybe I remembered wrongly). One could argue that type(Placeholder) could also be used for type annotations =/

Copy link
Copy Markdown

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

github-actions Bot added the stale Stale PR or inactive for long period of time. label Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL