Skip to content

Initial implementation of PEP 661 v2 (sentinels)#4

Open
JelleZijlstra wants to merge 83 commits intomainfrom
pep661
Open

Initial implementation of PEP 661 v2 (sentinels)#4
JelleZijlstra wants to merge 83 commits intomainfrom
pep661

Conversation

@JelleZijlstra
Copy link
Copy Markdown
Owner

@JelleZijlstra JelleZijlstra commented Apr 17, 2026


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

@JelleZijlstra
Copy link
Copy Markdown
Owner Author

Open questions:

  • What about __bool__? Lots of discussion on Discourse, I don't care too much but don't want this to derail the feature. This draft implementation says sentinels are always truthy.
  • Should sentinels be weakrefable?
  • Should the sentinel class be subclassable? My inclination is no.
  • Should there be a C API like PySentinel_New? Probably.

Comment thread Objects/sentinelobject.c
Comment thread Objects/sentinelobject.c Outdated
Comment thread Doc/library/functions.rst Outdated
Comment thread Doc/library/functions.rst
Comment thread Doc/library/functions.rst Outdated
@Viicos
Copy link
Copy Markdown

Viicos commented Apr 17, 2026

Open questions:

Gave thoughts on python/peps#4923 (comment).

skirpichev and others added 17 commits April 17, 2026 14:09
…ex types in the ctype module (pythonGH-148485)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
…hon#148657)

The option parsing in Modules/_zstd/decompressor.c had a missing Py_DECREF(value) before the early return -1 when PyLong_AsInt(key) fails. The identical code in Modules/_zstd/compressor.c line 158 has the fix.
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
)

Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
…le objects (pythonGH-148698)

Forbid marshalling recursive code, slice and frozendict objects which
cannot be correctly unmarshalled.
Reject invalid marshal data produced by marshalling recursive frozendict
objects which was previously incorrectly unmarshalled.
Add multiple tests for recursive data structures.
Co-authored-by: Stan Ulbrych <stan@python.org>
…#148689)

If _BlocksOutputBuffer_Finish() fails (memory allocation failure),
PyBytesWriter_Discard() is called on the writer. Then if
_BlocksOutputBuffer_OnError() is called, it calls again
PyBytesWriter_Discard() causing a double free.

Fix _BlocksOutputBuffer_Finish() by setting buffer->writer to NULL,
so _BlocksOutputBuffer_OnError() does nothing instead of calling
PyBytesWriter_Discard() again.
Copy link
Copy Markdown

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

I only looked at the .rst file as my minimal knowledge of C won't help much here. There are a couple of double spaces in some of them, perhaps before merging quickly grep for " " in the diff to remove those :)

@JelleZijlstra
Copy link
Copy Markdown
Owner Author

Thanks for looking! I think the double spaces are mainly between sentences, that's very common in the docs. It doesn't affect rendering.

sethmlarson and others added 30 commits April 22, 2026 19:22
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
…ases (python#143316)

The documentation previously stated that Concatenate is only valid
when used as the first argument to Callable, but according to PEP 612,
it can also be used when instantiating user-defined generic classes
with ParamSpec parameters.
…hints()` (python#143758)

Do not mention `__annotations__` dictionaries, as this is slightly
outdated since 3.14.

Rewrite the note about possible exceptions for clarity. Also do not
mention imported type aliases, as since 3.12 aliases with the `type`
statement do not suffer from this limitation anymore.
…pythonGH-148302)

Improve ABI/feature selection, add new header for it.

Add a test that Python headers themselves don't use
Py_GIL_DISABLED in abi3t: abi3 and abi3t ought to be the
same except the _Py_OPAQUE_PYOBJECT differences.
This is done using the GCC-only poison pragma.

Co-authored-by: Victor Stinner <vstinner@python.org>
… string representations of ForwardRef (python#148682)

Co-authored-by: Shamil <ashm.tech@proton.me>
…from both `ValueError` and `IndexError` (python#148664)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
… Lines file (python#132632)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
pythongh-148886)

Avoid racing with the owning thread's refcount operations when
immortalizing an interned string: if we don't own it and its refcount
isn't merged, intern a copy we own instead. Use atomic stores in
_Py_SetImmortalUntracked so concurrent atomic reads are race-free.
Add '+' alternatives to signed_number and signed_real_number grammar
rules, mirroring how unary minus is already handled for pattern matching.
Unary plus is a no-op on numbers so the value is returned directly without
wrapping in a UnaryOp node.
…ntend (pythonGH-148089)

* Replaces ad-hoc logic for ending traces with a simple inequality: `fitness < exit_quality`
* Fitness starts high and is reduced for branches, backward edges, calls and trace length
* Exit quality reflect how good a spot that instruction is to end a trace. Closing a loop is very, specializable instructions are very low and the others in between.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Improve  `hash()` builtin docstring with caveats.

Mention its return type and that the value can be expected to change between
processes (hash randomization).

Why? The `hash` builtin gets reached for and used by a lot of people whether it
is the right tool or not. IDEs surface docstrings and people use pydoc and
`help(hash)`.
Fixes python#108951

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Co-authored-by: Guido van Rossum <guido@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.