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-148829: Add PySentinel_CheckExact() by scoder · Pull Request #149725 · python/cpython

Conversation

@scoder

@scoder scoder commented May 12, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

As suggested in https://discuss.python.org/t/pep-661-sentinel-values/9126/343, this PR adds a PySentinel_CheckExact() C macro and makes PySentinel_Check() an alias, which can change if/when we allow subtypes in the future.

The discussion seems to suggest that subtyping will be valuable at some point. Adding both C macros now allows to write concise code on user side that (hopefully) requires less changes later.

I chose to make PySentinel_Check() an alias of PySentinel_CheckExact() and not the other way round because the current C macro actually does an exact check, so its correct name is PySentinel_CheckExact().

  • Issue: Implement PEP 661 Sentinel Values #148829

Sorry, something went wrong.

Uh oh!

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

All reactions
@scoder
Add PySentinel_CheckExact().
28ca03f
@scoder
scoder requested a review from ZeroIntensity as a code owner May 12, 2026 14:52
@scoder scoder added the needs backport to 3.15 bugs and security fixes label May 12, 2026
@bedevere-app bedevere-app Bot mentioned this pull request May 12, 2026
Implement PEP 661 Sentinel Values #148829
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label May 12, 2026
@scoder scoder added the skip news label May 12, 2026
@read-the-docs-community

read-the-docs-community Bot commented May 12, 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 #32670091 | 📁 Comparing 03f28f7 against main (0534774)

  🔍 Preview build  

20 files changed · ± 20 modified

± Modified

  • c-api/sentinel.html
  • deprecations/index.html
  • deprecations/pending-removal-in-3.16.html
  • library/base64.html
  • library/binascii.html
  • library/dataclasses.html
  • library/inspect.html
  • library/mimetypes.html
  • library/stdtypes.html
  • library/sys.html
  • and 10 more...
All reactions

Sorry, something went wrong.

Uh oh!

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

@scoder

scoder commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

I set the skipNews tag since we're still pre-release, but OTOH, we're post-beta1, so we might still want to add a news entry. Should I add one?

I was also mildly surprised to find the tests in object.c. By name, that seems quite generic for tests that belong to a specific builtin type.

All reactions

Sorry, something went wrong.

Uh oh!

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

@scoder

scoder commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

@vstinner @JelleZijlstra

All reactions

Sorry, something went wrong.

Uh oh!

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

@JelleZijlstra

JelleZijlstra commented May 12, 2026

Copy link
Copy Markdown
Member

Ah, sorry I forgot to follow up on this. I'm OK with the change and we should be able to do it in the beta phase, but we will need a NEWS entry since we already made a (beta) release with the old logic.

All reactions

Sorry, something went wrong.

Uh oh!

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

@scoder
Add NEWS entry.
60e8ab7
@scoder scoder removed the skip news label May 12, 2026
StanFromIreland
StanFromIreland reviewed May 12, 2026
View reviewed changes
Comment thread Misc/NEWS.d/next/C_API/2026-05-12-16-47-21.gh-issue-149725.HZLBTZ.rst Resolved

Uh oh!

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

Comment thread Doc/c-api/sentinel.rst Resolved

Uh oh!

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

Comment thread Doc/c-api/sentinel.rst Resolved

Uh oh!

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

Comment thread Doc/c-api/sentinel.rst Resolved

Uh oh!

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

scoder added 2 commits May 12, 2026 21:21
@scoder
Update documentation after code review.
090e023
@scoder
Add missing EOL.
0fa9656
vstinner
vstinner approved these changes May 13, 2026
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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.

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/c-api/sentinel.rst
Return true if *o* is a :class:`sentinel` object or a subtype.
The :class:`sentinel` type does not currently allow subclasses,
so this check is exact.
Future Python versions may choose to allow subtyping.

@vstinner vstinner May 13, 2026

Copy link
Copy Markdown
Member

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.

Can you add "This function always succeeds." to both functions?

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels May 13, 2026
@scoder
Docs: Add non-failure note to new functions.
03f28f7
@vstinner
vstinner enabled auto-merge (squash) May 13, 2026 09:44
@vstinner
vstinner merged commit 94df625 into python:main May 13, 2026
55 checks passed

Uh oh!

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

@miss-islington-app

miss-islington-app Bot commented May 13, 2026

Copy link
Copy Markdown

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

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 awaiting merge label May 13, 2026
@bedevere-app

bedevere-app Bot commented May 13, 2026

Copy link
Copy Markdown

GH-149766 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 13, 2026
@vstinner

vstinner commented May 13, 2026

Copy link
Copy Markdown
Member

Merged. Thanks @scoder for your contribution!

scoder 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.

vstinner pushed a commit that referenced this pull request May 13, 2026
@miss-islington @scoder
[3.15] gh-148829: Add PySentinel_CheckExact() (GH-149725) (#149766)
a5f77a1
gh-148829: Add PySentinel_CheckExact() (GH-149725)
(cherry picked from commit 94df625)

Co-authored-by: scoder <[email protected]>
@scoder
scoder deleted the pysentinel_checkexact branch May 13, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@StanFromIreland StanFromIreland StanFromIreland left review comments
@vstinner vstinner vstinner approved these changes
@ZeroIntensity ZeroIntensity Awaiting requested review from ZeroIntensity ZeroIntensity is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.

4 participants

@scoder @JelleZijlstra @vstinner @StanFromIreland
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.