Skip to content

Commit b32a8e2

Browse files
authored
Merge branch 'main' into branch-unique-reference-tracking
2 parents e4b7f51 + 08d7bd2 commit b32a8e2

File tree

80 files changed

+2179
-985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2179
-985
lines changed

Doc/c-api/module.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ To retrieve the state from a given module, use the following functions:
426426
module state.
427427
428428
429-
.. c:function:: int PyModule_GetStateSize(PyObject *, Py_ssize_t *result)
429+
.. c:function:: int PyModule_GetStateSize(PyObject *module, Py_ssize_t *result)
430430
431-
Set *\*result* to the size of the module's state, as specified using
432-
:c:macro:`Py_mod_state_size` (or :c:member:`PyModuleDef.m_size`),
431+
Set *\*result* to the size of *module*'s state, as specified
432+
using :c:macro:`Py_mod_state_size` (or :c:member:`PyModuleDef.m_size`),
433433
and return 0.
434434
435435
On error, set *\*result* to -1, and return -1 with an exception set.
@@ -597,7 +597,7 @@ A module's token -- and the *your_token* value to use in the above code -- is:
597597
598598
.. c:function:: int PyModule_GetToken(PyObject *module, void** result)
599599
600-
Set *\*result* to the module's token and return 0.
600+
Set *\*result* to the module token for *module* and return 0.
601601
602602
On error, set *\*result* to NULL, and return -1 with an exception set.
603603
@@ -645,7 +645,7 @@ rather than from an extension's :ref:`export hook <extension-export-hook>`.
645645
646646
.. c:function:: int PyModule_Exec(PyObject *module)
647647
648-
Execute the :c:data:`Py_mod_exec` slot(s) of the given *module*.
648+
Execute the :c:data:`Py_mod_exec` slot(s) of *module*.
649649
650650
On success, return 0.
651651
On error, return -1 with an exception set.
@@ -1021,6 +1021,9 @@ or code that creates modules dynamically.
10211021
``PyModuleDef`` (such as when using :ref:`multi-phase-initialization`,
10221022
``PyModule_Create``, or ``PyModule_FromDefAndSpec``).
10231023
1024+
Return ``0`` on success.
1025+
Return ``-1`` with an exception set on error.
1026+
10241027
.. versionadded:: 3.5
10251028
10261029
.. c:function:: int PyUnstable_Module_SetGIL(PyObject *module, void *gil)

Doc/library/base64.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ POST request.
7373

7474

7575
.. function:: b64decode(s, altchars=None, validate=False)
76+
b64decode(s, altchars=None, validate=True, *, ignorechars)
7677
7778
Decode the Base64 encoded :term:`bytes-like object` or ASCII string
7879
*s* and return the decoded :class:`bytes`.
@@ -84,11 +85,17 @@ POST request.
8485
A :exc:`binascii.Error` exception is raised
8586
if *s* is incorrectly padded.
8687

87-
If *validate* is false (the default), characters that are neither
88+
If *ignorechars* is specified, it should be a :term:`bytes-like object`
89+
containing characters to ignore from the input when *validate* is true.
90+
The default value of *validate* is ``True`` if *ignorechars* is specified,
91+
``False`` otherwise.
92+
93+
If *validate* is false, characters that are neither
8894
in the normal base-64 alphabet nor the alternative alphabet are
8995
discarded prior to the padding check, but the ``+`` and ``/`` characters
9096
keep their meaning if they are not in *altchars* (they will be discarded
9197
in future Python versions).
98+
9299
If *validate* is true, these non-alphabet characters in the input
93100
result in a :exc:`binascii.Error`.
94101

@@ -99,6 +106,10 @@ POST request.
99106
is now deprecated.
100107

101108

109+
.. versionchanged:: next
110+
Added the *ignorechars* parameter.
111+
112+
102113
.. function:: standard_b64encode(s)
103114

104115
Encode :term:`bytes-like object` *s* using the standard Base64 alphabet

Doc/library/binascii.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,16 @@ The :mod:`binascii` module defines the following functions:
4949

5050

5151
.. function:: a2b_base64(string, /, *, strict_mode=False)
52+
a2b_base64(string, /, *, strict_mode=True, ignorechars)
5253
5354
Convert a block of base64 data back to binary and return the binary data. More
5455
than one line may be passed at a time.
5556

57+
If *ignorechars* is specified, it should be a :term:`bytes-like object`
58+
containing characters to ignore from the input when *strict_mode* is true.
59+
The default value of *strict_mode* is ``True`` if *ignorechars* is specified,
60+
``False`` otherwise.
61+
5662
If *strict_mode* is true, only valid base64 data will be converted. Invalid base64
5763
data will raise :exc:`binascii.Error`.
5864

@@ -66,6 +72,9 @@ The :mod:`binascii` module defines the following functions:
6672
.. versionchanged:: 3.11
6773
Added the *strict_mode* parameter.
6874

75+
.. versionchanged:: next
76+
Added the *ignorechars* parameter.
77+
6978

7079
.. function:: b2a_base64(data, *, wrapcol=0, newline=True)
7180

Doc/library/contextvars.rst

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,32 @@ Context Variables
7777
to restore the variable to its previous value via the
7878
:meth:`ContextVar.reset` method.
7979

80+
For convenience, the token object can be used as a context manager
81+
to avoid calling :meth:`ContextVar.reset` manually::
82+
83+
var = ContextVar('var', default='default value')
84+
85+
with var.set('new value'):
86+
assert var.get() == 'new value'
87+
88+
assert var.get() == 'default value'
89+
90+
It is a shorthand for::
91+
92+
var = ContextVar('var', default='default value')
93+
94+
token = var.set('new value')
95+
try:
96+
assert var.get() == 'new value'
97+
finally:
98+
var.reset(token)
99+
100+
assert var.get() == 'default value'
101+
102+
.. versionadded:: 3.14
103+
104+
Added support for using tokens as context managers.
105+
80106
.. method:: reset(token)
81107

82108
Reset the context variable to the value it had before the
@@ -93,24 +119,18 @@ Context Variables
93119
# After the reset call the var has no value again, so
94120
# var.get() would raise a LookupError.
95121

122+
The same *token* cannot be used twice.
123+
96124

97125
.. class:: Token
98126

99127
*Token* objects are returned by the :meth:`ContextVar.set` method.
100128
They can be passed to the :meth:`ContextVar.reset` method to revert
101129
the value of the variable to what it was before the corresponding
102-
*set*.
103-
104-
The token supports :ref:`context manager protocol <context-managers>`
105-
to restore the corresponding context variable value at the exit from
106-
:keyword:`with` block::
107-
108-
var = ContextVar('var', default='default value')
109-
110-
with var.set('new value'):
111-
assert var.get() == 'new value'
130+
*set*. A single token cannot reset a context variable more than once.
112131

113-
assert var.get() == 'default value'
132+
Tokens support the :ref:`context manager protocol <context-managers>`
133+
to automatically reset context variables. See :meth:`ContextVar.set`.
114134

115135
.. versionadded:: 3.14
116136

Doc/library/os.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4262,7 +4262,7 @@ features:
42624262
import os
42634263

42644264
# semaphore with start value '1'
4265-
fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFC_CLOEXEC)
4265+
fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFD_CLOEXEC)
42664266
try:
42674267
# acquire semaphore
42684268
v = os.eventfd_read(fd)

Doc/library/pickle.rst

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,6 @@ files.
5656

5757
The :mod:`pickle` module differs from :mod:`marshal` in several significant ways:
5858

59-
* The :mod:`pickle` module keeps track of the objects it has already serialized,
60-
so that later references to the same object won't be serialized again.
61-
:mod:`marshal` doesn't do this.
62-
63-
This has implications both for recursive objects and object sharing. Recursive
64-
objects are objects that contain references to themselves. These are not
65-
handled by marshal, and in fact, attempting to marshal recursive objects will
66-
crash your Python interpreter. Object sharing happens when there are multiple
67-
references to the same object in different places in the object hierarchy being
68-
serialized. :mod:`pickle` stores such objects only once, and ensures that all
69-
other references point to the master copy. Shared objects remain shared, which
70-
can be very important for mutable objects.
71-
7259
* :mod:`marshal` cannot be used to serialize user-defined classes and their
7360
instances. :mod:`pickle` can save and restore class instances transparently,
7461
however the class definition must be importable and live in the same module as

Doc/library/symtable.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ Examining Symbol Tables
180180
Return a tuple containing names of :term:`free (closure) variables <closure variable>`
181181
in this function.
182182

183+
.. method:: get_cells()
184+
185+
Return a tuple containing names of :term:`cell variables <closure variable>` in this table.
186+
187+
.. versionadded:: next
188+
183189

184190
.. class:: Class
185191

@@ -291,6 +297,12 @@ Examining Symbol Tables
291297
Return ``True`` if the symbol is referenced in its block, but not assigned
292298
to.
293299

300+
.. method:: is_cell()
301+
302+
Return ``True`` if the symbol is referenced but not assigned in a nested block.
303+
304+
.. versionadded:: next
305+
294306
.. method:: is_free_class()
295307

296308
Return *True* if a class-scoped symbol is free from

Doc/reference/datamodel.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ Special read-only attributes
546546
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
547547

548548
.. index::
549+
single: __builtins__ (function attribute)
549550
single: __closure__ (function attribute)
550551
single: __globals__ (function attribute)
551552
pair: global; namespace
@@ -556,6 +557,12 @@ Special read-only attributes
556557
* - Attribute
557558
- Meaning
558559

560+
* - .. attribute:: function.__builtins__
561+
- A reference to the :class:`dictionary <dict>` that holds the function's
562+
builtins namespace.
563+
564+
.. versionadded:: 3.10
565+
559566
* - .. attribute:: function.__globals__
560567
- A reference to the :class:`dictionary <dict>` that holds the function's
561568
:ref:`global variables <naming>` -- the global namespace of the module

Doc/whatsnew/3.15.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,18 @@ base64
444444
* Added the *wrapcol* parameter in :func:`~base64.b64encode`.
445445
(Contributed by Serhiy Storchaka in :gh:`143214`.)
446446

447+
* Added the *ignorechars* parameter in :func:`~base64.b64decode`.
448+
(Contributed by Serhiy Storchaka in :gh:`144001`.)
447449

448450
binascii
449451
--------
450452

451453
* Added the *wrapcol* parameter in :func:`~binascii.b2a_base64`.
452454
(Contributed by Serhiy Storchaka in :gh:`143214`.)
453455

456+
* Added the *ignorechars* parameter in :func:`~binascii.a2b_base64`.
457+
(Contributed by Serhiy Storchaka in :gh:`144001`.)
458+
454459

455460
calendar
456461
--------
@@ -603,8 +608,10 @@ math
603608
mimetypes
604609
---------
605610

611+
* Add ``application/dicom`` MIME type for ``.dcm`` extension. (Contributed by Benedikt Johannes in :gh:`144217`.)
606612
* Add ``application/node`` MIME type for ``.cjs`` extension. (Contributed by John Franey in :gh:`140937`.)
607613
* Add ``application/toml``. (Contributed by Gil Forcada in :gh:`139959`.)
614+
* Add ``image/jxl``. (Contributed by Foolbar in :gh:`144213`.)
608615
* Rename ``application/x-texinfo`` to ``application/texinfo``.
609616
(Contributed by Charlie Lin in :gh:`140165`.)
610617
* Changed the MIME type for ``.ai`` files to ``application/pdf``.
@@ -737,6 +744,13 @@ ssl
737744
(Contributed by Ron Frederick in :gh:`138252`.)
738745

739746

747+
symtable
748+
--------
749+
750+
* Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods.
751+
(Contributed by Yashp002 in :gh:`143504`.)
752+
753+
740754
sys
741755
---
742756

Include/internal/pycore_code.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,17 +292,7 @@ extern int _PyCode_SafeAddr2Line(PyCodeObject *co, int addr);
292292
extern void _PyCode_Clear_Executors(PyCodeObject *code);
293293

294294

295-
#ifdef Py_GIL_DISABLED
296-
// gh-115999 tracks progress on addressing this.
297-
#define ENABLE_SPECIALIZATION 0
298-
// Use this to enable specialization families once they are thread-safe. All
299-
// uses will be replaced with ENABLE_SPECIALIZATION once all families are
300-
// thread-safe.
301-
#define ENABLE_SPECIALIZATION_FT 1
302-
#else
303295
#define ENABLE_SPECIALIZATION 1
304-
#define ENABLE_SPECIALIZATION_FT ENABLE_SPECIALIZATION
305-
#endif
306296

307297
/* Specialization functions, these are exported only for other re-generated
308298
* interpreters to call */

0 commit comments

Comments
 (0)