Skip to content

Commit 5d9911a

Browse files
committed
Merge branch 'master' into ac-decimal/73487
2 parents 98b0e38 + 715647a commit 5d9911a

34 files changed

+1319
-342
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ jobs:
178178
free-threading: ${{ matrix.free-threading }}
179179

180180
build-windows-msi:
181-
name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category
182-
Windows MSI${{ '' }}
181+
# ${{ '' } is a hack to nest jobs under the same sidebar category.
182+
name: Windows MSI${{ '' }} # zizmor: ignore[obfuscation]
183183
needs: build-context
184184
if: fromJSON(needs.build-context.outputs.run-windows-msi)
185185
strategy:
@@ -586,8 +586,8 @@ jobs:
586586
run: xvfb-run make ci
587587

588588
build-san:
589-
name: >- # ${{ '' } is a hack to nest jobs under the same sidebar category
590-
Sanitizers${{ '' }}
589+
# ${{ '' } is a hack to nest jobs under the same sidebar category.
590+
name: Sanitizers${{ '' }} # zizmor: ignore[obfuscation]
591591
needs: build-context
592592
if: needs.build-context.outputs.run-tests == 'true'
593593
strategy:

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.11.8
3+
rev: v0.12.8
44
hooks:
55
- id: ruff
66
name: Run Ruff (lint) on Doc/
@@ -42,7 +42,7 @@ repos:
4242
exclude: ^Tools/c-analyzer/cpython/_parser.py
4343

4444
- repo: https://github.com/pre-commit/pre-commit-hooks
45-
rev: v5.0.0
45+
rev: v6.0.0
4646
hooks:
4747
- id: check-case-conflict
4848
- id: check-merge-conflict
@@ -60,7 +60,7 @@ repos:
6060
files: '^\.github/CODEOWNERS|\.(gram)$'
6161

6262
- repo: https://github.com/python-jsonschema/check-jsonschema
63-
rev: 0.33.0
63+
rev: 0.33.2
6464
hooks:
6565
- id: check-dependabot
6666
- id: check-github-workflows
@@ -72,7 +72,7 @@ repos:
7272
- id: actionlint
7373

7474
- repo: https://github.com/woodruffw/zizmor-pre-commit
75-
rev: v1.6.0
75+
rev: v1.11.0
7676
hooks:
7777
- id: zizmor
7878

Doc/c-api/complex.rst

Lines changed: 103 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -3,116 +3,10 @@
33
.. _complexobjects:
44

55
Complex Number Objects
6-
----------------------
6+
======================
77

88
.. index:: pair: object; complex number
99

10-
Python's complex number objects are implemented as two distinct types when
11-
viewed from the C API: one is the Python object exposed to Python programs, and
12-
the other is a C structure which represents the actual complex number value.
13-
The API provides functions for working with both.
14-
15-
16-
Complex Numbers as C Structures
17-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18-
19-
Note that the functions which accept these structures as parameters and return
20-
them as results do so *by value* rather than dereferencing them through
21-
pointers. This is consistent throughout the API.
22-
23-
24-
.. c:type:: Py_complex
25-
26-
The C structure which corresponds to the value portion of a Python complex
27-
number object. Most of the functions for dealing with complex number objects
28-
use structures of this type as input or output values, as appropriate.
29-
30-
.. c:member:: double real
31-
double imag
32-
33-
The structure is defined as::
34-
35-
typedef struct {
36-
double real;
37-
double imag;
38-
} Py_complex;
39-
40-
41-
.. c:function:: Py_complex _Py_c_sum(Py_complex left, Py_complex right)
42-
43-
Return the sum of two complex numbers, using the C :c:type:`Py_complex`
44-
representation.
45-
46-
.. deprecated:: 3.15
47-
This function is :term:`soft deprecated`.
48-
49-
50-
.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
51-
52-
Return the difference between two complex numbers, using the C
53-
:c:type:`Py_complex` representation.
54-
55-
.. deprecated:: 3.15
56-
This function is :term:`soft deprecated`.
57-
58-
59-
.. c:function:: Py_complex _Py_c_neg(Py_complex num)
60-
61-
Return the negation of the complex number *num*, using the C
62-
:c:type:`Py_complex` representation.
63-
64-
.. deprecated:: 3.15
65-
This function is :term:`soft deprecated`.
66-
67-
68-
.. c:function:: Py_complex _Py_c_prod(Py_complex left, Py_complex right)
69-
70-
Return the product of two complex numbers, using the C :c:type:`Py_complex`
71-
representation.
72-
73-
.. deprecated:: 3.15
74-
This function is :term:`soft deprecated`.
75-
76-
77-
.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
78-
79-
Return the quotient of two complex numbers, using the C :c:type:`Py_complex`
80-
representation.
81-
82-
If *divisor* is null, this method returns zero and sets
83-
:c:data:`errno` to :c:macro:`!EDOM`.
84-
85-
.. deprecated:: 3.15
86-
This function is :term:`soft deprecated`.
87-
88-
89-
.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
90-
91-
Return the exponentiation of *num* by *exp*, using the C :c:type:`Py_complex`
92-
representation.
93-
94-
If *num* is null and *exp* is not a positive real number,
95-
this method returns zero and sets :c:data:`errno` to :c:macro:`!EDOM`.
96-
97-
Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.
98-
99-
.. deprecated:: 3.15
100-
This function is :term:`soft deprecated`.
101-
102-
103-
.. c:function:: double _Py_c_abs(Py_complex num)
104-
105-
Return the absolute value of the complex number *num*.
106-
107-
Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.
108-
109-
.. deprecated:: 3.15
110-
This function is :term:`soft deprecated`.
111-
112-
113-
Complex Numbers as Python Objects
114-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
115-
11610

11711
.. c:type:: PyComplexObject
11812
@@ -147,12 +41,6 @@ Complex Numbers as Python Objects
14741
:c:type:`PyComplexObject`. This function always succeeds.
14842
14943
150-
.. c:function:: PyObject* PyComplex_FromCComplex(Py_complex v)
151-
152-
Create a new Python complex number object from a C :c:type:`Py_complex` value.
153-
Return ``NULL`` with an exception set on error.
154-
155-
15644
.. c:function:: PyObject* PyComplex_FromDoubles(double real, double imag)
15745
15846
Return a new :c:type:`PyComplexObject` object from *real* and *imag*.
@@ -191,6 +79,29 @@ Complex Numbers as Python Objects
19179
.. versionchanged:: 3.13
19280
Use :meth:`~object.__complex__` if available.
19381
82+
83+
.. c:type:: Py_complex
84+
85+
This C structure defines export format for a Python complex
86+
number object.
87+
88+
.. c:member:: double real
89+
double imag
90+
91+
The structure is defined as::
92+
93+
typedef struct {
94+
double real;
95+
double imag;
96+
} Py_complex;
97+
98+
99+
.. c:function:: PyObject* PyComplex_FromCComplex(Py_complex v)
100+
101+
Create a new Python complex number object from a C :c:type:`Py_complex` value.
102+
Return ``NULL`` with an exception set on error.
103+
104+
194105
.. c:function:: Py_complex PyComplex_AsCComplex(PyObject *op)
195106
196107
Return the :c:type:`Py_complex` value of the complex number *op*.
@@ -207,3 +118,82 @@ Complex Numbers as Python Objects
207118
208119
.. versionchanged:: 3.8
209120
Use :meth:`~object.__index__` if available.
121+
122+
123+
Complex Numbers as C Structures
124+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125+
126+
The API also provides functions for working with complex numbers, using the
127+
:c:type:`Py_complex` representation. Note that the functions which accept
128+
these structures as parameters and return them as results do so *by value*
129+
rather than dereferencing them through pointers.
130+
131+
Please note, that these functions are :term:`soft deprecated` since Python
132+
3.15. Avoid using this API in a new code to do complex arithmetic: either use
133+
the `Number Protocol <number>`_ API or use native complex types, like
134+
:c:expr:`double complex`.
135+
136+
137+
.. c:function:: Py_complex _Py_c_sum(Py_complex left, Py_complex right)
138+
139+
Return the sum of two complex numbers, using the C :c:type:`Py_complex`
140+
representation.
141+
142+
.. deprecated:: 3.15
143+
144+
145+
.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
146+
147+
Return the difference between two complex numbers, using the C
148+
:c:type:`Py_complex` representation.
149+
150+
.. deprecated:: 3.15
151+
152+
153+
.. c:function:: Py_complex _Py_c_neg(Py_complex num)
154+
155+
Return the negation of the complex number *num*, using the C
156+
:c:type:`Py_complex` representation.
157+
158+
.. deprecated:: 3.15
159+
160+
161+
.. c:function:: Py_complex _Py_c_prod(Py_complex left, Py_complex right)
162+
163+
Return the product of two complex numbers, using the C :c:type:`Py_complex`
164+
representation.
165+
166+
.. deprecated:: 3.15
167+
168+
169+
.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
170+
171+
Return the quotient of two complex numbers, using the C :c:type:`Py_complex`
172+
representation.
173+
174+
If *divisor* is null, this method returns zero and sets
175+
:c:data:`errno` to :c:macro:`!EDOM`.
176+
177+
.. deprecated:: 3.15
178+
179+
180+
.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
181+
182+
Return the exponentiation of *num* by *exp*, using the C :c:type:`Py_complex`
183+
representation.
184+
185+
If *num* is null and *exp* is not a positive real number,
186+
this method returns zero and sets :c:data:`errno` to :c:macro:`!EDOM`.
187+
188+
Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.
189+
190+
.. deprecated:: 3.15
191+
192+
193+
.. c:function:: double _Py_c_abs(Py_complex num)
194+
195+
Return the absolute value of the complex number *num*.
196+
197+
Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.
198+
199+
.. deprecated:: 3.15

Doc/c-api/hash.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
5151
5252
Hash function definition used by :c:func:`PyHash_GetFuncDef`.
5353

54-
.. c::member:: Py_hash_t (*const hash)(const void *, Py_ssize_t)
54+
.. c:member:: Py_hash_t (*const hash)(const void *, Py_ssize_t)
5555
5656
Hash function.
5757

Doc/library/functions.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,9 +1220,9 @@ are always available. They are listed here in alphabetical order.
12201220
Added the *strict* parameter.
12211221

12221222

1223-
.. function:: max(iterable, *, key=None)
1224-
max(iterable, *, default, key=None)
1225-
max(arg1, arg2, *args, key=None)
1223+
.. function:: max(iterable, /, *, key=None)
1224+
max(iterable, /, *, default, key=None)
1225+
max(arg1, arg2, /, *args, key=None)
12261226
12271227
Return the largest item in an iterable or the largest of two or more
12281228
arguments.
@@ -1258,9 +1258,9 @@ are always available. They are listed here in alphabetical order.
12581258
:ref:`typememoryview` for more information.
12591259

12601260

1261-
.. function:: min(iterable, *, key=None)
1262-
min(iterable, *, default, key=None)
1263-
min(arg1, arg2, *args, key=None)
1261+
.. function:: min(iterable, /, *, key=None)
1262+
min(iterable, /, *, default, key=None)
1263+
min(arg1, arg2, /, *args, key=None)
12641264
12651265
Return the smallest item in an iterable or the smallest of two or more
12661266
arguments.
@@ -1729,8 +1729,8 @@ are always available. They are listed here in alphabetical order.
17291729

17301730

17311731
.. _func-range:
1732-
.. class:: range(stop)
1733-
range(start, stop, step=1)
1732+
.. class:: range(stop, /)
1733+
range(start, stop, step=1, /)
17341734
:noindex:
17351735

17361736
Rather than being a function, :class:`range` is actually an immutable

Doc/library/importlib.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ ABC hierarchy::
393393
.. deprecated:: 3.7
394394
This ABC is deprecated in favour of supporting resource loading
395395
through :class:`importlib.resources.abc.TraversableResources`.
396+
This class exists for backwards compatibility only with other ABCs in
397+
this module.
396398

397399
.. method:: get_data(path)
398400
:abstractmethod:

Include/internal/pycore_magic_number.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ Known values:
277277
Python 3.14a7 3622 (Store annotations in different class dict keys)
278278
Python 3.14a7 3623 (Add BUILD_INTERPOLATION & BUILD_TEMPLATE opcodes)
279279
Python 3.14b1 3624 (Don't optimize LOAD_FAST when local is killed by DELETE_FAST)
280+
Python 3.14b3 3625 (Fix handling of opcodes that may leave operands on the stack when optimizing LOAD_FAST)
281+
Python 3.14rc2 3626 (Fix missing exception handlers in logical expression)
280282
Python 3.15a0 3650 (Initial version)
281283
Python 3.15a1 3651 (Simplify LOAD_CONST)
282284
Python 3.15a1 3652 (Virtual iterators)

Lib/dataclasses.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,10 @@ def _add_slots(cls, is_frozen, weakref_slot, defined_fields):
12831283
if '__slots__' in cls.__dict__:
12841284
raise TypeError(f'{cls.__name__} already specifies __slots__')
12851285

1286+
# gh-102069: Remove existing __weakref__ descriptor.
1287+
# gh-135228: Make sure the original class can be garbage collected.
1288+
sys._clear_type_descriptors(cls)
1289+
12861290
# Create a new dict for our new class.
12871291
cls_dict = dict(cls.__dict__)
12881292
field_names = tuple(f.name for f in fields(cls))
@@ -1300,12 +1304,6 @@ def _add_slots(cls, is_frozen, weakref_slot, defined_fields):
13001304
# available in _MARKER.
13011305
cls_dict.pop(field_name, None)
13021306

1303-
# Remove __dict__ itself.
1304-
cls_dict.pop('__dict__', None)
1305-
1306-
# Clear existing `__weakref__` descriptor, it belongs to a previous type:
1307-
cls_dict.pop('__weakref__', None) # gh-102069
1308-
13091307
# And finally create the class.
13101308
qualname = getattr(cls, '__qualname__', None)
13111309
newcls = type(cls)(cls.__name__, cls.__bases__, cls_dict)

0 commit comments

Comments
 (0)