Skip to content

Commit 6269f68

Browse files
authored
Merge branch 'main' into frozenset_immutable_tracking
2 parents 6027391 + 9181d77 commit 6269f68

57 files changed

Lines changed: 2594 additions & 1362 deletions

Some content is hidden

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

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ Lib/test/test_stable_abi_ctypes.py generated
9494
Lib/test/test_zoneinfo/data/*.json generated
9595
Lib/token.py generated
9696
Misc/sbom.spdx.json generated
97+
Modules/_testinternalcapi/test_cases.c.h generated
98+
Modules/_testinternalcapi/test_targets.h generated
9799
Objects/typeslots.inc generated
98100
PC/python3dll.c generated
99101
Parser/parser.c generated

Doc/library/contextvars.rst

Lines changed: 28 additions & 10 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
@@ -101,16 +127,8 @@ Context Variables
101127
the value of the variable to what it was before the corresponding
102128
*set*.
103129

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'
112-
113-
assert var.get() == 'default value'
130+
Tokens support the :ref:`context manager protocol <context-managers>`
131+
to automatically reset context variables. See :meth:`ContextVar.set`.
114132

115133
.. versionadded:: 3.14
116134

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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,10 @@ math
603603
mimetypes
604604
---------
605605

606+
* Add ``application/dicom`` MIME type for ``.dcm`` extension. (Contributed by Benedikt Johannes in :gh:`144217`.)
606607
* Add ``application/node`` MIME type for ``.cjs`` extension. (Contributed by John Franey in :gh:`140937`.)
607608
* Add ``application/toml``. (Contributed by Gil Forcada in :gh:`139959`.)
609+
* Add ``image/jxl``. (Contributed by Foolbar in :gh:`144213`.)
608610
* Rename ``application/x-texinfo`` to ``application/texinfo``.
609611
(Contributed by Charlie Lin in :gh:`140165`.)
610612
* Changed the MIME type for ``.ai`` files to ``application/pdf``.
@@ -737,6 +739,13 @@ ssl
737739
(Contributed by Ron Frederick in :gh:`138252`.)
738740

739741

742+
symtable
743+
--------
744+
745+
* Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods.
746+
(Contributed by Yashp002 in :gh:`143504`.)
747+
748+
740749
sys
741750
---
742751

Include/internal/pycore_opcode_metadata.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_optimizer_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ typedef struct {
7676
typedef enum {
7777
JIT_PRED_IS,
7878
JIT_PRED_IS_NOT,
79+
JIT_PRED_EQ,
80+
JIT_PRED_NE,
7981
} JitOptPredicateKind;
8082

8183
typedef struct {

0 commit comments

Comments
 (0)