Skip to content

Commit ec80e9b

Browse files
committed
Merge branch 'main' into ruff-format
2 parents ef24b96 + fac41f5 commit ec80e9b

File tree

143 files changed

+4353
-1766
lines changed

Some content is hidden

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

143 files changed

+4353
-1766
lines changed

.github/workflows/jit.yml

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ jobs:
9595
with:
9696
python-version: '3.11'
9797

98+
# PCbuild downloads LLVM automatically:
9899
- name: Windows
99100
if: runner.os == 'Windows'
100101
run: |
101-
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
102102
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
103103
./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
104104
@@ -126,29 +126,30 @@ jobs:
126126
make all --jobs 4
127127
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
128128
129-
jit-with-disabled-gil:
130-
name: Free-Threaded (Debug)
131-
needs: interpreter
132-
runs-on: ubuntu-24.04
133-
timeout-minutes: 90
134-
strategy:
135-
fail-fast: false
136-
matrix:
137-
llvm:
138-
- 19
139-
steps:
140-
- uses: actions/checkout@v4
141-
with:
142-
persist-credentials: false
143-
- uses: actions/setup-python@v5
144-
with:
145-
python-version: '3.11'
146-
- name: Build with JIT enabled and GIL disabled
147-
run: |
148-
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
149-
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
150-
./configure --enable-experimental-jit --with-pydebug --disable-gil
151-
make all --jobs 4
152-
- name: Run tests
153-
run: |
154-
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
129+
# XXX: GH-133171
130+
# jit-with-disabled-gil:
131+
# name: Free-Threaded (Debug)
132+
# needs: interpreter
133+
# runs-on: ubuntu-24.04
134+
# timeout-minutes: 90
135+
# strategy:
136+
# fail-fast: false
137+
# matrix:
138+
# llvm:
139+
# - 19
140+
# steps:
141+
# - uses: actions/checkout@v4
142+
# with:
143+
# persist-credentials: false
144+
# - uses: actions/setup-python@v5
145+
# with:
146+
# python-version: '3.11'
147+
# - name: Build with JIT enabled and GIL disabled
148+
# run: |
149+
# sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
150+
# export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
151+
# ./configure --enable-experimental-jit --with-pydebug --disable-gil
152+
# make all --jobs 4
153+
# - name: Run tests
154+
# run: |
155+
# ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3

Doc/c-api/float.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ NaNs (if such things exist on the platform) isn't handled correctly, and
9696
attempting to unpack a bytes string containing an IEEE INF or NaN will raise an
9797
exception.
9898
99+
Note that NaNs type may not be preserved on IEEE platforms (silent NaN become
100+
quiet), for example on x86 systems in 32-bit mode.
101+
99102
On non-IEEE platforms with more precision, or larger dynamic range, than IEEE
100103
754 supports, not all values can be packed; on non-IEEE platforms with less
101104
precision, or smaller dynamic range, not all values can be unpacked. What

Doc/c-api/object.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,38 @@ Object Protocol
613613
614614
.. versionadded:: 3.14
615615
616+
.. c:function:: int PyUnstable_Object_IsUniqueReferencedTemporary(PyObject *obj)
617+
618+
Check if *obj* is a unique temporary object.
619+
Returns ``1`` if *obj* is known to be a unique temporary object,
620+
and ``0`` otherwise. This function cannot fail, but the check is
621+
conservative, and may return ``0`` in some cases even if *obj* is a unique
622+
temporary object.
623+
624+
If an object is a unique temporary, it is guaranteed that the current code
625+
has the only reference to the object. For arguments to C functions, this
626+
should be used instead of checking if the reference count is ``1``. Starting
627+
with Python 3.14, the interpreter internally avoids some reference count
628+
modifications when loading objects onto the operands stack by
629+
:term:`borrowing <borrowed reference>` references when possible, which means
630+
that a reference count of ``1`` by itself does not guarantee that a function
631+
argument uniquely referenced.
632+
633+
In the example below, ``my_func`` is called with a unique temporary object
634+
as its argument::
635+
636+
my_func([1, 2, 3])
637+
638+
In the example below, ``my_func`` is **not** called with a unique temporary
639+
object as its argument, even if its refcount is ``1``::
640+
641+
my_list = [1, 2, 3]
642+
my_func(my_list)
643+
644+
See also the function :c:func:`Py_REFCNT`.
645+
646+
.. versionadded:: 3.14
647+
616648
.. c:function:: int PyUnstable_IsImmortal(PyObject *obj)
617649
618650
This function returns non-zero if *obj* is :term:`immortal`, and zero

Doc/c-api/refcounting.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ of Python objects.
2323
2424
Use the :c:func:`Py_SET_REFCNT()` function to set an object reference count.
2525
26+
See also the function :c:func:`PyUnstable_Object_IsUniqueReferencedTemporary()`.
27+
2628
.. versionchanged:: 3.10
2729
:c:func:`Py_REFCNT()` is changed to the inline static function.
2830

Doc/deprecations/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ Deprecations
55

66
.. include:: pending-removal-in-3.16.rst
77

8+
.. include:: pending-removal-in-3.17.rst
9+
810
.. include:: pending-removal-in-future.rst
911

1012
C API deprecations
1113
------------------
1214

1315
.. include:: c-api-pending-removal-in-3.15.rst
1416

17+
.. include:: c-api-pending-removal-in-3.18.rst
18+
1519
.. include:: c-api-pending-removal-in-future.rst

Doc/deprecations/pending-removal-in-3.16.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ Pending removal in Python 3.16
6161
* Calling the Python implementation of :func:`functools.reduce` with *function*
6262
or *sequence* as keyword arguments has been deprecated since Python 3.14.
6363

64+
* :mod:`logging`:
65+
66+
Support for custom logging handlers with the *strm* argument is deprecated
67+
and scheduled for removal in Python 3.16. Define handlers with the *stream*
68+
argument instead. (Contributed by Mariusz Felisiak in :gh:`115032`.)
69+
6470
* :mod:`mimetypes`:
6571

6672
* Valid extensions start with a '.' or are empty for
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Pending removal in Python 3.17
2+
------------------------------
3+
4+
* :mod:`typing`:
5+
6+
- Before Python 3.14, old-style unions were implemented using the private class
7+
``typing._UnionGenericAlias``. This class is no longer needed for the implementation,
8+
but it has been retained for backward compatibility, with removal scheduled for Python
9+
3.17. Users should use documented introspection helpers like :func:`typing.get_origin`
10+
and :func:`typing.get_args` instead of relying on private implementation details.

Doc/library/argparse.rst

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ ArgumentParser objects
7474
prefix_chars='-', fromfile_prefix_chars=None, \
7575
argument_default=None, conflict_handler='error', \
7676
add_help=True, allow_abbrev=True, exit_on_error=True, \
77-
suggest_on_error=False)
77+
*, suggest_on_error=False, color=False)
7878
7979
Create a new :class:`ArgumentParser` object. All parameters should be passed
8080
as keyword arguments. Each parameter has its own more detailed description
@@ -111,14 +111,15 @@ ArgumentParser objects
111111
* add_help_ - Add a ``-h/--help`` option to the parser (default: ``True``)
112112

113113
* allow_abbrev_ - Allows long options to be abbreviated if the
114-
abbreviation is unambiguous. (default: ``True``)
114+
abbreviation is unambiguous (default: ``True``)
115115

116116
* exit_on_error_ - Determines whether or not :class:`!ArgumentParser` exits with
117117
error info when an error occurs. (default: ``True``)
118118

119119
* suggest_on_error_ - Enables suggestions for mistyped argument choices
120120
and subparser names (default: ``False``)
121121

122+
* color_ - Allow color output (default: ``False``)
122123

123124
.. versionchanged:: 3.5
124125
*allow_abbrev* parameter was added.
@@ -130,6 +131,9 @@ ArgumentParser objects
130131
.. versionchanged:: 3.9
131132
*exit_on_error* parameter was added.
132133

134+
.. versionchanged:: 3.14
135+
*suggest_on_error* and *color* parameters were added.
136+
133137
The following sections describe how each of these are used.
134138

135139

@@ -594,7 +598,8 @@ subparser names, the feature can be enabled by setting ``suggest_on_error`` to
594598
``True``. Note that this only applies for arguments when the choices specified
595599
are strings::
596600

597-
>>> parser = argparse.ArgumentParser(description='Process some integers.', suggest_on_error=True)
601+
>>> parser = argparse.ArgumentParser(description='Process some integers.',
602+
suggest_on_error=True)
598603
>>> parser.add_argument('--action', choices=['sum', 'max'])
599604
>>> parser.add_argument('integers', metavar='N', type=int, nargs='+',
600605
... help='an integer for the accumulator')
@@ -612,6 +617,33 @@ keyword argument::
612617
.. versionadded:: 3.14
613618

614619

620+
color
621+
^^^^^
622+
623+
By default, the help message is printed in plain text. If you want to allow
624+
color in help messages, you can enable it by setting ``color`` to ``True``::
625+
626+
>>> parser = argparse.ArgumentParser(description='Process some integers.',
627+
... color=True)
628+
>>> parser.add_argument('--action', choices=['sum', 'max'])
629+
>>> parser.add_argument('integers', metavar='N', type=int, nargs='+',
630+
... help='an integer for the accumulator')
631+
>>> parser.parse_args(['--help'])
632+
633+
Even if a CLI author has enabled color, it can be
634+
:ref:`controlled using environment variables <using-on-controlling-color>`.
635+
636+
If you're writing code that needs to be compatible with older Python versions
637+
and want to opportunistically use ``color`` when it's available, you
638+
can set it as an attribute after initializing the parser instead of using the
639+
keyword argument::
640+
641+
>>> parser = argparse.ArgumentParser(description='Process some integers.')
642+
>>> parser.color = True
643+
644+
.. versionadded:: next
645+
646+
615647
The add_argument() method
616648
-------------------------
617649

Doc/library/ctypes.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2172,10 +2172,20 @@ Utility functions
21722172

21732173
.. function:: POINTER(type, /)
21742174

2175-
Create and return a new ctypes pointer type. Pointer types are cached and
2175+
Create or return a ctypes pointer type. Pointer types are cached and
21762176
reused internally, so calling this function repeatedly is cheap.
21772177
*type* must be a ctypes type.
21782178

2179+
.. impl-detail::
2180+
2181+
The resulting pointer type is cached in the ``__pointer_type__``
2182+
attribute of *type*.
2183+
It is possible to set this attribute before the first call to
2184+
``POINTER`` in order to set a custom pointer type.
2185+
However, doing this is discouraged: manually creating a suitable
2186+
pointer type is difficult without relying on implementation
2187+
details that may change in future Python versions.
2188+
21792189

21802190
.. function:: pointer(obj, /)
21812191

@@ -2340,6 +2350,16 @@ Data types
23402350
library. *name* is the name of the symbol that exports the data, *library*
23412351
is the loaded shared library.
23422352

2353+
Common class variables of ctypes data types:
2354+
2355+
.. attribute:: __pointer_type__
2356+
2357+
The pointer type that was created by calling
2358+
:func:`POINTER` for corresponding ctypes data type. If a pointer type
2359+
was not yet created, the attribute is missing.
2360+
2361+
.. versionadded:: next
2362+
23432363
Common instance variables of ctypes data types:
23442364

23452365
.. attribute:: _b_base_

Doc/library/struct.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,24 +260,17 @@ platform-dependent.
260260
+--------+--------------------------+--------------------+----------------+------------+
261261
| ``d`` | :c:expr:`double` | float | 8 | \(4) |
262262
+--------+--------------------------+--------------------+----------------+------------+
263+
| ``F`` | :c:expr:`float complex` | complex | 8 | \(10) |
264+
+--------+--------------------------+--------------------+----------------+------------+
265+
| ``D`` | :c:expr:`double complex` | complex | 16 | \(10) |
266+
+--------+--------------------------+--------------------+----------------+------------+
263267
| ``s`` | :c:expr:`char[]` | bytes | | \(9) |
264268
+--------+--------------------------+--------------------+----------------+------------+
265269
| ``p`` | :c:expr:`char[]` | bytes | | \(8) |
266270
+--------+--------------------------+--------------------+----------------+------------+
267271
| ``P`` | :c:expr:`void \*` | integer | | \(5) |
268272
+--------+--------------------------+--------------------+----------------+------------+
269273

270-
Additionally, if IEC 60559 compatible complex arithmetic (Annex G of the
271-
C11 standard) is supported, the following format characters are available:
272-
273-
+--------+--------------------------+--------------------+----------------+------------+
274-
| Format | C Type | Python type | Standard size | Notes |
275-
+========+==========================+====================+================+============+
276-
| ``F`` | :c:expr:`float complex` | complex | 8 | \(10) |
277-
+--------+--------------------------+--------------------+----------------+------------+
278-
| ``D`` | :c:expr:`double complex` | complex | 16 | \(10) |
279-
+--------+--------------------------+--------------------+----------------+------------+
280-
281274
.. versionchanged:: 3.3
282275
Added support for the ``'n'`` and ``'N'`` formats.
283276

@@ -364,9 +357,14 @@ Notes:
364357
``'0c'`` means 0 characters).
365358

366359
(10)
367-
For the ``'E'`` and ``'C'`` format characters, the packed representation uses
360+
For the ``'F'`` and ``'D'`` format characters, the packed representation uses
368361
the IEEE 754 binary32 and binary64 format for components of the complex
369362
number, regardless of the floating-point format used by the platform.
363+
Note that complex types (``F`` and ``D``) are available unconditionally,
364+
despite complex types being an optional feature in C.
365+
As specified in the C11 standard, each complex type is represented by a
366+
two-element C array containing, respectively, the real and imaginary parts.
367+
370368

371369
A format character may be preceded by an integral repeat count. For example,
372370
the format string ``'4h'`` means exactly the same as ``'hhhh'``.

0 commit comments

Comments
 (0)