8000 Merge branch 'main' into no_complex.h/61103 · python/cpython@b18d895 · GitHub
[go: up one dir, main page]

Skip to content

Commit b18d895

Browse files
authored
Merge branch 'main' into no_complex.h/61103
2 parents 071d57e + 987e45e commit b18d895

File tree

101 files changed

+2916
-1367
lines changed

Some content is hidden

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

101 files changed

+2916
-1367
lines changed

.github/workflows/jit.yml

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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

.ruff.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Default settings for Ruff in CPython
2+
3+
# PYTHON_FOR_REGEN
4+
target-version = "py310"
5+
6+
# PEP 8
7+
line-length = 79
8+
9+
# Enable automatic fixes by default.
10+
# To override this, use ``fix = false`` in a subdirectory's config file
11+
# or ``--no-fix`` on the command line.
12+
fix = true

Android/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ it:
2525
`android-sdk/cmdline-tools/latest`.
2626
* `export ANDROID_HOME=/path/to/android-sdk`
2727

28-
The `android.py` script also requires the following commands to be on the `PATH`:
28+
The `android.py` script will automatically use the SDK's `sdkmanager` to install
29+
any packages it needs.
30+
31+
The script also requires the following commands to be on the `PATH`:
2932

3033
* `curl`
3134
* `java` (or set the `JAVA_HOME` environment variable)
32-
* `tar`
3335

3436

3537
## Building
@@ -97,7 +99,7 @@ similar to the `Android` directory of the CPython source tree.
9799
The Python test suite can be run on Linux, macOS, or Windows:
98100

99101
* On Linux, the emulator needs access to the KVM virtualization interface, and
100-
a DISPLAY environment variable pointing at an X server.
102+
a DISPLAY environment variable pointing at an X server. Xvfb is acceptable.
101103

102104
The test suite can usually be run on a device with 2 GB of RAM, but this is
103105
borderline, so you may need to increase it to 4 GB. As of Android

Android/android.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,19 @@ def make_build_python(context):
138138
run(["make", "-j", str(os.cpu_count())])
139139

140140

141-
def unpack_deps(host):
141+
def unpack_deps(host, prefix_dir):
142142
deps_url = "https://github.com/beeware/cpython-android-source-deps/releases/download"
143143
for name_ver in ["bzip2-1.0.8-2", "libffi-3.4.4-3", "openssl-3.0.15-4",
144144
"sqlite-3.49.1-0", "xz-5.4.6-1"]:
145145
filename = f"{name_ver}-{host}.tar.gz"
146146
download(f"{deps_url}/{name_ver}/{filename}")
147-
run(["tar", "-xf", filename])
147+
shutil.unpack_archive(filename, prefix_dir)
148148
os.remove(filename)
149149

150150

151151
def download(url, target_dir="."):
152152
out_path = f"{target_dir}/{basename(url)}"
153-
run(["curl", "-Lf", "-o", out_path, url])
153+
run(["curl", "-Lf", "--retry", "5", "--retry-all-errors", "-o", out_path, url])
154154
return out_path
155155

156156

@@ -162,8 +162,7 @@ def configure_host_python(context):
162162
prefix_dir = host_dir / "prefix"
163163
if not prefix_dir.exists():
164164
prefix_dir.mkdir()
165-
os.chdir(prefix_dir)
166-
unpack_deps(context.host)
165+
unpack_deps(context.host, prefix_dir)
167166

168167
os.chdir(host_dir)
169168
command = [
@@ -241,16 +240,15 @@ def setup_sdk():
241240
# the Gradle wrapper is not included in the CPython repository. Instead, we
242241
# extract it from the Gradle GitHub repository.
243242
def setup_testbed():
244-
# The Gradle version used for the build is specified in
245-
# testbed/gradle/wrapper/gradle-wrapper.properties. This wrapper version
246-
# doesn't need to match, as any version of the wrapper can download any
247-
# version of Gradle.
248-
version = "8.9.0"
249243
paths = ["gradlew", "gradlew.bat", "gradle/wrapper/gradle-wrapper.jar"]
250-
251244
if all((TESTBED_DIR / path).exists() for path in paths):
252245
return
253246

247+
# The wrapper version isn't important, as any version of the wrapper can
248+
# download any version of Gradle. The Gradle version actually used for the
249+
# build is specified in testbed/gradle/wrapper/gradle-wrapper.properties.
250+
version = "8.9.0"
251+
254252
for path in paths:
255253
out_path = TESTBED_DIR / path
256254
out_path.parent.mkdir(exist_ok=True)

Doc/.ruff.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
extend = "../.ruff.toml" # Inherit the project-wide settings
2+
13
target-version = "py312" # Align with the version in oldest_supported_sphinx
2-
fix = true
3-
output-format = "full"
4-
line-length = 79
54
extend-exclude = [
65
"includes/*",
76
# Temporary exclusions:

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/struct.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ Notes:
357357
``'0c'`` means 0 characters).
358358

359359
(10)
360-
For the ``'E'`` and ``'C'`` format characters, the packed representation uses
360+
For the ``'F'`` and ``'D'`` format characters, the packed representation uses
361361
the IEEE 754 binary32 and binary64 format for components of the complex
362362
number, regardless of the floating-point format used by the platform.
363363
Note that complex types (``F`` and ``D``) are available unconditionally,

Doc/library/turtle.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
=================================
2-
:mod:`turtle` --- Turtle graphics
3-
=================================
1+
==================================
2+
:mod:`!turtle` --- Turtle graphics
3+
==================================
44

55
.. module:: turtle
66
:synopsis: An educational framework for simple graphics applications

Doc/library/typing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
========================================
2-
:mod:`typing` --- Support for type hints
3-
========================================
1+
=========================================
2+
:mod:`!typing` --- Support for type hints
3+
=========================================
44

55
.. testsetup:: *
66

Doc/whatsnew/3.12.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,8 @@ Deprecated
13471347

13481348
.. include:: ../deprecations/pending-removal-in-3.16.rst
13491349

1350+
.. include:: ../deprecations/pending-removal-in-3.17.rst
1351+
13501352
.. include:: ../deprecations/pending-removal-in-future.rst
13511353

13521354
.. _whatsnew312-removed:

Doc/whatsnew/3.13.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,8 @@ New Deprecations
20092009

20102010
.. include:: ../deprecations/pending-removal-in-3.16.rst
20112011

2012+
.. include:: ../deprecations/pending-removal-in-3.17.rst
2013+
20122014
.. include:: ../deprecations/pending-removal-in-future.rst
20132015

20142016
CPython Bytecode Changes
@@ -2529,6 +2531,8 @@ Deprecated C APIs
25292531

25302532
.. include:: ../deprecations/c-api-pending-removal-in-3.15.rst
25312533

2534+
.. include:: ../deprecations/c-api-pending-removal-in-3.18.rst
2535+
25322536
.. include:: ../deprecations/c-api-pending-removal-in-future.rst
25332537

25342538
.. _pythoncapi-compat project: https://github.com/python/pythoncapi-compat/

0 commit comments

Comments
 (0)
0