Skip to content

Commit 71a2ea8

Browse files
Deploy preview for PR 1193 🛫
1 parent 124930f commit 71a2ea8

File tree

578 files changed

+692
-624
lines changed

Some content is hidden

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

578 files changed

+692
-624
lines changed

pr-preview/pr-1193/_sources/faq/programming.rst.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,13 +1226,13 @@ This converts the list into a set, thereby removing duplicates, and then back
12261226
into a list.
12271227

12281228

1229-
How do you remove multiple items from a list
1230-
--------------------------------------------
1229+
How do you remove multiple items from a list?
1230+
---------------------------------------------
12311231

12321232
As with removing duplicates, explicitly iterating in reverse with a
12331233
delete condition is one possibility. However, it is easier and faster
12341234
to use slice replacement with an implicit or explicit forward iteration.
1235-
Here are three variations.::
1235+
Here are three variations::
12361236

12371237
mylist[:] = filter(keep_function, mylist)
12381238
mylist[:] = (x for x in mylist if keep_condition)

pr-preview/pr-1193/_sources/library/contextvars.rst.txt

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

pr-preview/pr-1193/_sources/library/os.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3880,7 +3880,7 @@ features:
38803880
import os
38813881

38823882
# semaphore with start value '1'
3883-
fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFC_CLOEXEC)
3883+
fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFD_CLOEXEC)
38843884
try:
38853885
# acquire semaphore
38863886
v = os.eventfd_read(fd)

pr-preview/pr-1193/_sources/library/pickle.rst.txt

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

pr-preview/pr-1193/_sources/reference/datamodel.rst.txt

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

pr-preview/pr-1193/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ <h3>導航</h3>
326326
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
327327
<br>
328328
<br>
329-
最後更新於 1月 24, 2026 (22:53 UTC)。
329+
最後更新於 1月 27, 2026 (00:22 UTC)。
330330

331331
<a href="/bugs.html">發現 bug</a>
332332

pr-preview/pr-1193/bugs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ <h3>導航</h3>
363363
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
364364
<br>
365365
<br>
366-
最後更新於 1月 24, 2026 (22:53 UTC)。
366+
最後更新於 1月 27, 2026 (00:22 UTC)。
367367

368368
<a href="/bugs.html">發現 bug</a>
369369

pr-preview/pr-1193/c-api/abstract.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ <h3>導航</h3>
335335
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
336336
<br>
337337
<br>
338-
最後更新於 1月 24, 2026 (22:53 UTC)。
338+
最後更新於 1月 27, 2026 (00:22 UTC)。
339339

340340
<a href="/bugs.html">發現 bug</a>
341341

pr-preview/pr-1193/c-api/allocation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ <h3>導航</h3>
544544
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
545545
<br>
546546
<br>
547-
最後更新於 1月 24, 2026 (22:53 UTC)。
547+
最後更新於 1月 27, 2026 (00:22 UTC)。
548548

549549
<a href="/bugs.html">發現 bug</a>
550550

pr-preview/pr-1193/c-api/apiabiversion.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ <h3>導航</h3>
484484
<a href="https://www.python.org/psf/donations/">敬請捐贈。</a>
485485
<br>
486486
<br>
487-
最後更新於 1月 24, 2026 (22:53 UTC)。
487+
最後更新於 1月 27, 2026 (00:22 UTC)。
488488

489489
<a href="/bugs.html">發現 bug</a>
490490

0 commit comments

Comments
 (0)