Skip to content

Commit 67d942f

Browse files
authored
Merge branch 'main' into json_ft
2 parents d4ddf5d + 4055577 commit 67d942f

File tree

175 files changed

+4129
-3134
lines changed

Some content is hidden

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

175 files changed

+4129
-3134
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Python/ceval*.h @markshannon
3434
Python/compile.c @markshannon @iritkatriel
3535
Python/assemble.c @markshannon @iritkatriel
3636
Python/flowgraph.c @markshannon @iritkatriel
37+
Python/instruction_sequence.c @iritkatriel
3738
Python/ast_opt.c @isidentical
3839
Python/bytecodes.c @markshannon
3940
Python/optimizer*.c @markshannon
@@ -74,11 +75,8 @@ Programs/python.c @ericsnowcurrently
7475
Tools/build/generate_global_objects.py @ericsnowcurrently
7576

7677
# Exceptions
77-
Lib/traceback.py @iritkatriel
7878
Lib/test/test_except*.py @iritkatriel
79-
Lib/test/test_traceback.py @iritkatriel
8079
Objects/exceptions.c @iritkatriel
81-
Python/traceback.c @iritkatriel
8280

8381
# Hashing
8482
**/*hashlib* @gpshead @tiran

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ jobs:
199199
uses: ./.github/workflows/reusable-macos.yml
200200
with:
201201
config_hash: ${{ needs.check_source.outputs.config_hash }}
202-
# macos-14 is M1, macos-13 is Intel
203-
os-matrix: '["macos-14", "macos-13"]'
202+
# Cirrus is M1, macos-13 is default GHA Intel
203+
os-matrix: '["ghcr.io/cirruslabs/macos-runner:sonoma", "macos-13"]'
204204

205205
build_macos_free_threading:
206206
name: 'macOS (free-threading)'
@@ -210,8 +210,8 @@ jobs:
210210
with:
211211
config_hash: ${{ needs.check_source.outputs.config_hash }}
212212
free-threading: true
213-
# macos-14-large is Intel with 12 cores (most parallelism)
214-
os-matrix: '["macos-14"]'
213+
# Cirrus is M1
214+
os-matrix: '["ghcr.io/cirruslabs/macos-runner:sonoma"]'
215215

216216
build_ubuntu:
217217
name: 'Ubuntu'

Doc/c-api/long.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,19 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
494494
.. versionadded:: 3.13
495495
496496
497+
.. c:function:: int PyLong_GetSign(PyObject *obj, int *sign)
498+
499+
Get the sign of the integer object *obj*.
500+
501+
On success, set *\*sign* to the integer sign (0, -1 or +1 for zero, negative or
502+
positive integer, respectively) and return 0.
503+
504+
On failure, return -1 with an exception set. This function always succeeds
505+
if *obj* is a :c:type:`PyLongObject` or its subtype.
506+
507+
.. versionadded:: 3.14
508+
509+
497510
.. c:function:: int PyUnstable_Long_IsCompact(const PyLongObject* op)
498511
499512
Return 1 if *op* is compact, 0 otherwise.

Doc/c-api/monitoring.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
.. _monitoring:
44

5-
Monitorong C API
5+
Monitoring C API
66
================
77

88
Added in version 3.13.

Doc/c-api/reflection.rst

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,48 @@ Reflection
77

88
.. c:function:: PyObject* PyEval_GetBuiltins(void)
99
10+
.. deprecated:: 3.13
11+
12+
Use :c:func:`PyEval_GetFrameBuiltins` instead.
13+
1014
Return a dictionary of the builtins in the current execution frame,
1115
or the interpreter of the thread state if no frame is currently executing.
1216
1317
1418
.. c:function:: PyObject* PyEval_GetLocals(void)
1519
16-
Return a dictionary of the local variables in the current execution frame,
20+
.. deprecated:: 3.13
21+
22+
Use either :c:func:`PyEval_GetFrameLocals` to obtain the same behaviour as calling
23+
:func:`locals` in Python code, or else call :c:func:`PyFrame_GetLocals` on the result
24+
of :c:func:`PyEval_GetFrame` to access the :attr:`~frame.f_locals` attribute of the
25+
currently executing frame.
26+
27+
Return a mapping providing access to the local variables in the current execution frame,
1728
or ``NULL`` if no frame is currently executing.
1829
30+
Refer to :func:`locals` for details of the mapping returned at different scopes.
31+
32+
As this function returns a :term:`borrowed reference`, the dictionary returned for
33+
:term:`optimized scopes <optimized scope>` is cached on the frame object and will remain
34+
alive as long as the frame object does. Unlike :c:func:`PyEval_GetFrameLocals` and
35+
:func:`locals`, subsequent calls to this function in the same frame will update the
36+
contents of the cached dictionary to reflect changes in the state of the local variables
37+
rather than returning a new snapshot.
38+
39+
.. versionchanged:: 3.13
40+
As part of :pep:`667`, :c:func:`PyFrame_GetLocals`, :func:`locals`, and
41+
:attr:`FrameType.f_locals <frame.f_locals>` no longer make use of the shared cache
42+
dictionary. Refer to the :ref:`What's New entry <whatsnew313-locals-semantics>` for
43+
additional details.
44+
1945
2046
.. c:function:: PyObject* PyEval_GetGlobals(void)
2147
48+
.. deprecated:: 3.13
49+
50+
Use :c:func:`PyEval_GetFrameGlobals` instead.
51+
2252
Return a dictionary of the global variables in the current execution frame,
2353
or ``NULL`` if no frame is currently executing.
2454
@@ -31,6 +61,36 @@ Reflection
3161
See also :c:func:`PyThreadState_GetFrame`.
3262
3363
64+
.. c:function:: PyObject* PyEval_GetFrameBuiltins(void)
65+
66+
Return a dictionary of the builtins in the current execution frame,
67+
or the interpreter of the thread state if no frame is currently executing.
68+
69+
.. versionadded:: 3.13
70+
71+
72+
.. c:function:: PyObject* PyEval_GetFrameLocals(void)
73+
74+
Return a dictionary of the local variables in the current execution frame,
75+
or ``NULL`` if no frame is currently executing. Equivalent to calling
76+
:func:`locals` in Python code.
77+
78+
To access :attr:`~frame.f_locals` on the current frame without making an independent
79+
snapshot in :term:`optimized scopes <optimized scope>`, call :c:func:`PyFrame_GetLocals`
80+
on the result of :c:func:`PyEval_GetFrame`.
81+
82+
.. versionadded:: 3.13
83+
84+
85+
.. c:function:: PyObject* PyEval_GetFrameGlobals(void)
86+
87+
Return a dictionary of the global variables in the current execution frame,
88+
or ``NULL`` if no frame is currently executing. Equivalent to calling
89+
:func:`globals` in Python code.
90+
91+
.. versionadded:: 3.13
92+
93+
3494
.. c:function:: const char* PyEval_GetFuncName(PyObject *func)
3595
3696
Return the name of *func* if it is a function, class or instance object, else the

Doc/data/refcounts.dat

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,12 @@ PyEval_GetGlobals:PyObject*::0:
790790

791791
PyEval_GetFrame:PyObject*::0:
792792

793+
PyEval_GetFrameBuiltins:PyObject*::+1:
794+
795+
PyEval_GetFrameLocals:PyObject*::+1:
796+
797+
PyEval_GetFrameGlobals:PyObject*::+1:
798+
793799
PyEval_GetFuncDesc:const char*:::
794800
PyEval_GetFuncDesc:PyObject*:func:0:
795801

@@ -916,6 +922,32 @@ PyFloat_FromString:PyObject*:str:0:
916922
PyFloat_GetInfo:PyObject*::+1:
917923
PyFloat_GetInfo::void::
918924

925+
PyFrame_GetBack:PyObject*::+1:
926+
PyFrame_GetBack:PyFrameObject*:frame:0:
927+
928+
PyFrame_GetBuiltins:PyObject*::+1:
929+
PyFrame_GetBuiltins:PyFrameObject*:frame:0:
930+
931+
PyFrame_GetCode:PyObject*::+1:
932+
PyFrame_GetCode:PyFrameObject*:frame:0:
933+
934+
PyFrame_GetGenerator:PyObject*::+1:
935+
PyFrame_GetGenerator:PyFrameObject*:frame:0:
936+
937+
PyFrame_GetGlobals:PyObject*::+1:
938+
PyFrame_GetGlobals:PyFrameObject*:frame:0:
939+
940+
PyFrame_GetLocals:PyObject*::+1:
941+
PyFrame_GetLocals:PyFrameObject*:frame:0:
942+
943+
PyFrame_GetVar:PyObject*::+1:
944+
PyFrame_GetVar:PyFrameObject*:frame:0:
945+
PyFrame_GetVar:PyObject*:name:0:
946+
947+
PyFrame_GetVarString:PyObject*::+1:
948+
PyFrame_GetVarString:PyFrameObject*:frame:0:
949+
PyFrame_GetVarString:const char*:name::
950+
919951
PyFrozenSet_Check:int:::
920952
PyFrozenSet_Check:PyObject*:p:0:
921953

Doc/howto/logging-cookbook.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2950,7 +2950,7 @@ When run, this produces a file with exactly two lines:
29502950
.. code-block:: none
29512951
29522952
28/01/2015 07:21:23|INFO|Sample message|
2953-
28/01/2015 07:21:23|ERROR|ZeroDivisionError: integer division or modulo by zero|'Traceback (most recent call last):\n File "logtest7.py", line 30, in main\n x = 1 / 0\nZeroDivisionError: integer division or modulo by zero'|
2953+
28/01/2015 07:21:23|ERROR|ZeroDivisionError: division by zero|'Traceback (most recent call last):\n File "logtest7.py", line 30, in main\n x = 1 / 0\nZeroDivisionError: division by zero'|
29542954
29552955
While the above treatment is simplistic, it points the way to how exception
29562956
information can be formatted to your liking. The :mod:`traceback` module may be

Doc/library/functions.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,9 +1004,8 @@ are always available. They are listed here in alphabetical order.
10041004
115
10051005

10061006
If the argument defines :meth:`~object.__int__`,
1007-
``int(x)`` returns ``x.__int__()``. If the argument defines :meth:`~object.__index__`,
1008-
it returns ``x.__index__()``. If the argument defines :meth:`~object.__trunc__`,
1009-
it returns ``x.__trunc__()``.
1007+
``int(x)`` returns ``x.__int__()``. If the argument defines
1008+
:meth:`~object.__index__`, it returns ``x.__index__()``.
10101009
For floating point numbers, this truncates towards zero.
10111010

10121011
If the argument is not a number or if *base* is given, then it must be a string,
@@ -1044,9 +1043,6 @@ are always available. They are listed here in alphabetical order.
10441043
.. versionchanged:: 3.8
10451044
Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not defined.
10461045

1047-
.. versionchanged:: 3.11
1048-
The delegation to :meth:`~object.__trunc__` is deprecated.
1049-
10501046
.. versionchanged:: 3.11
10511047
:class:`int` string inputs and string representations can be limited to
10521048
help avoid denial of service attacks. A :exc:`ValueError` is raised when
@@ -1055,6 +1051,9 @@ are always available. They are listed here in alphabetical order.
10551051
See the :ref:`integer string conversion length limitation
10561052
<int_max_str_digits>` documentation.
10571053

1054+
.. versionchanged:: 3.14
1055+
:func:`int` no longer delegates to the :meth:`~object.__trunc__` method.
1056+
10581057
.. function:: isinstance(object, classinfo)
10591058

10601059
Return ``True`` if the *object* argument is an instance of the *classinfo*

Doc/library/itertools.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,15 +857,15 @@ and :term:`generators <generator>` which incur interpreter overhead.
857857
return len(take(2, groupby(iterable, key))) <= 1
858858

859859
def unique_justseen(iterable, key=None):
860-
"List unique elements, preserving order. Remember only the element just seen."
860+
"Yield unique elements, preserving order. Remember only the element just seen."
861861
# unique_justseen('AAAABBBCCDAABBB') → A B C D A B
862862
# unique_justseen('ABBcCAD', str.casefold) → A B c A D
863863
if key is None:
864864
return map(operator.itemgetter(0), groupby(iterable))
865865
return map(next, map(operator.itemgetter(1), groupby(iterable, key)))
866866

867867
def unique_everseen(iterable, key=None):
868-
"List unique elements, preserving order. Remember all elements ever seen."
868+
"Yield unique elements, preserving order. Remember all elements ever seen."
869869
# unique_everseen('AAAABBBCCDAABBB') → A B C D
870870
# unique_everseen('ABBcCAD', str.casefold) → A B c D
871871
seen = set()
@@ -880,6 +880,11 @@ and :term:`generators <generator>` which incur interpreter overhead.
880880
seen.add(k)
881881
yield element
882882

883+
def unique(iterable, key=None, reverse=False):
884+
"Yield unique elements in sorted order. Supports unhashable inputs."
885+
# unique([[1, 2], [3, 4], [1, 2]]) → [1, 2] [3, 4]
886+
return unique_justseen(sorted(iterable, key=key, reverse=reverse), key=key)
887+
883888
def sliding_window(iterable, n):
884889
"Collect data into overlapping fixed-length chunks or blocks."
885890
# sliding_window('ABCDEFG', 4) → ABCD BCDE CDEF DEFG
@@ -1605,6 +1610,13 @@ The following recipes have a more mathematical flavor:
16051610
>>> ''.join(input_iterator)
16061611
'AAABBBCCDAABBB'
16071612

1613+
>>> list(unique([[1, 2], [3, 4], [1, 2]]))
1614+
[[1, 2], [3, 4]]
1615+
>>> list(unique('ABBcCAD', str.casefold))
1616+
['A', 'B', 'c', 'D']
1617+
>>> list(unique('ABBcCAD', str.casefold, reverse=True))
1618+
['D', 'c', 'B', 'A']
1619+
16081620
>>> d = dict(a=1, b=2, c=3)
16091621
>>> it = iter_except(d.popitem, KeyError)
16101622
>>> d['d'] = 4

0 commit comments

Comments
 (0)