Skip to content

Commit fb73967

Browse files
committed
Merge branch 'main' into gh-127794
2 parents aaa8879 + e62e1ca commit fb73967

Some content is hidden

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

60 files changed

+963
-407
lines changed

.github/workflows/reusable-windows-msi.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ jobs:
2424
with:
2525
persist-credentials: false
2626
- name: Build CPython installer
27-
run: .\Tools\msi\build.bat --doc -"${ARCH}"
27+
run: ./Tools/msi/build.bat --doc -"${ARCH}"
28+
shell: bash

Doc/c-api/frame.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,34 @@ See also :ref:`Reflection <reflection>`.
132132
.. versionadded:: 3.11
133133
134134
.. versionchanged:: 3.13
135-
As part of :pep:`667`, return a proxy object for optimized scopes.
135+
As part of :pep:`667`, return an instance of :c:var:`PyFrameLocalsProxy_Type`.
136136
137137
138138
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
139139
140140
Return the line number that *frame* is currently executing.
141141
142142
143+
Frame Locals Proxies
144+
^^^^^^^^^^^^^^^^^^^^
145+
146+
.. versionadded:: 3.13
147+
148+
The :attr:`~frame.f_locals` attribute on a :ref:`frame object <frame-objects>`
149+
is an instance of a "frame-locals proxy". The proxy object exposes a
150+
write-through view of the underlying locals dictionary for the frame. This
151+
ensures that the variables exposed by ``f_locals`` are always up to date with
152+
the live local variables in the frame itself.
153+
154+
See :pep:`667` for more information.
155+
156+
.. c:var:: PyTypeObject PyFrameLocalsProxy_Type
157+
158+
The type of frame :func:`locals` proxy objects.
159+
160+
.. c:function:: int PyFrameLocalsProxy_Check(PyObject *obj)
161+
162+
Return non-zero if *obj* is a frame :func:`locals` proxy.
143163
144164
Internal Frames
145165
^^^^^^^^^^^^^^^

Doc/c-api/object.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ Object Protocol
509509
iterated.
510510
511511
512+
.. c:function:: PyObject* PyObject_SelfIter(PyObject *obj)
513+
514+
This is equivalent to the Python ``__iter__(self): return self`` method.
515+
It is intended for :term:`iterator` types, to be used in the :c:member:`PyTypeObject.tp_iter` slot.
516+
517+
512518
.. c:function:: PyObject* PyObject_GetAIter(PyObject *o)
513519
514520
This is the equivalent to the Python expression ``aiter(o)``. Takes an

Doc/data/refcounts.dat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,9 @@ PyObject_RichCompareBool:PyObject*:o1:0:
18491849
PyObject_RichCompareBool:PyObject*:o2:0:
18501850
PyObject_RichCompareBool:int:opid::
18511851

1852+
PyObject_SelfIter:PyObject*::+1:
1853+
PyObject_SelfIter:PyObject*:obj:0:
1854+
18521855
PyObject_SetAttr:int:::
18531856
PyObject_SetAttr:PyObject*:o:0:
18541857
PyObject_SetAttr:PyObject*:attr_name:0:

Doc/library/http.cookies.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Cookie Objects
9898
.. method:: BaseCookie.output(attrs=None, header='Set-Cookie:', sep='\r\n')
9999

100100
Return a string representation suitable to be sent as HTTP headers. *attrs* and
101-
*header* are sent to each :class:`Morsel`'s :meth:`output` method. *sep* is used
101+
*header* are sent to each :class:`Morsel`'s :meth:`~Morsel.output` method. *sep* is used
102102
to join the headers together, and is by default the combination ``'\r\n'``
103103
(CRLF).
104104

Doc/library/itertools.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ The following recipes have a more mathematical flavor:
10151015
.. testcode::
10161016

10171017
def powerset(iterable):
1018-
"powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
1018+
# powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)
10191019
s = list(iterable)
10201020
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
10211021

@@ -1104,11 +1104,6 @@ The following recipes have a more mathematical flavor:
11041104
data[p*p : n : p+p] = bytes(len(range(p*p, n, p+p)))
11051105
yield from iter_index(data, 1, start=3)
11061106

1107-
def is_prime(n):
1108-
"Return True if n is prime."
1109-
# is_prime(1_000_000_000_000_403) → True
1110-
return n > 1 and all(n % p for p in sieve(math.isqrt(n) + 1))
1111-
11121107
def factor(n):
11131108
"Prime factors of n."
11141109
# factor(99) → 3 3 11
@@ -1123,6 +1118,11 @@ The following recipes have a more mathematical flavor:
11231118
if n > 1:
11241119
yield n
11251120

1121+
def is_prime(n):
1122+
"Return True if n is prime."
1123+
# is_prime(1_000_000_000_000_403) → True
1124+
return n > 1 and next(factor(n)) == n
1125+
11261126
def totient(n):
11271127
"Count of natural numbers up to n that are coprime to n."
11281128
# https://mathworld.wolfram.com/TotientFunction.html

Doc/library/traceback.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ Module-Level Functions
274274
:class:`!TracebackException` objects are created from actual exceptions to
275275
capture data for later printing. They offer a more lightweight method of
276276
storing this information by avoiding holding references to
277-
:ref:`traceback<traceback-objects>` and :ref:`frame<frame-objects>` objects
277+
:ref:`traceback<traceback-objects>` and :ref:`frame<frame-objects>` objects.
278278
In addition, they expose more options to configure the output compared to
279279
the module-level functions described above.
280280

Include/internal/pycore_freelist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static inline int
5151
_PyFreeList_Push(struct _Py_freelist *fl, void *obj, Py_ssize_t maxsize)
5252
{
5353
if (fl->size < maxsize && fl->size >= 0) {
54-
*(void **)obj = fl->freelist;
54+
FT_ATOMIC_STORE_PTR_RELAXED(*(void **)obj, fl->freelist);
5555
fl->freelist = obj;
5656
fl->size++;
5757
OBJECT_STAT_INC(to_freelist);

Include/internal/pycore_freelist_state.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern "C" {
1414
# define Py_dicts_MAXFREELIST 80
1515
# define Py_dictkeys_MAXFREELIST 80
1616
# define Py_floats_MAXFREELIST 100
17+
# define Py_ints_MAXFREELIST 100
1718
# define Py_slices_MAXFREELIST 1
1819
# define Py_contexts_MAXFREELIST 255
1920
# define Py_async_gens_MAXFREELIST 80
@@ -35,6 +36,7 @@ struct _Py_freelist {
3536

3637
struct _Py_freelists {
3738
struct _Py_freelist floats;
39+
struct _Py_freelist ints;
3840
struct _Py_freelist tuples[PyTuple_MAXSAVESIZE];
3941
struct _Py_freelist lists;
4042
struct _Py_freelist dicts;

Include/internal/pycore_global_objects_fini_generated.h

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

0 commit comments

Comments
 (0)