Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ef57e9

Browse files
Merge branch 'main' into gh-100926-ctypes-pointers-cache
2 parents cb78a03 + a6ddd07 commit 4ef57e9

File tree

370 files changed

+16786
-6235
lines changed

Some content is hidden

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

370 files changed

+16786
-6235
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,9 @@ Lib/test/test__colorize.py @hugovk
320320

321321
# Fuzzing
322322
Modules/_xxtestfuzz/ @ammaraskar
323+
324+
# t-strings
325+
**/*interpolationobject* @lysnikolaou
326+
**/*templateobject* @lysnikolaou
327+
**/*templatelib* @lysnikolaou
328+
**/*tstring* @lysnikolaou

.github/workflows/jit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ jobs:
113113
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
114114
brew install llvm@${{ matrix.llvm }}
115115
export SDKROOT="$(xcrun --show-sdk-path)"
116-
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }}
116+
./configure --enable-experimental-jit --enable-universalsdk --with-universal-archs=universal2 ${{ matrix.debug && '--with-pydebug' || '' }}
117117
make all --jobs 4
118118
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
119119

.github/workflows/mypy.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ on:
88
pull_request:
99
paths:
1010
- ".github/workflows/mypy.yml"
11+
- "Lib/_colorize.py"
1112
- "Lib/_pyrepl/**"
1213
- "Lib/test/libregrtest/**"
14+
- "Lib/tomllib/**"
15+
- "Misc/mypy/**"
1316
- "Tools/build/generate_sbom.py"
1417
- "Tools/cases_generator/**"
1518
- "Tools/clinic/**"
@@ -42,6 +45,7 @@ jobs:
4245
target: [
4346
"Lib/_pyrepl",
4447
"Lib/test/libregrtest",
48+
"Lib/tomllib",
4549
"Tools/build",
4650
"Tools/cases_generator",
4751
"Tools/clinic",

.github/workflows/reusable-docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
run: |
6767
set -Eeuo pipefail
6868
# Build docs with the nit-picky option; write warnings to file
69-
make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --nitpicky --fail-on-warning --keep-going --warning-file sphinx-warnings.txt" html
69+
make -C Doc/ PYTHON=../python SPHINXOPTS="--quiet --nitpicky --fail-on-warning --warning-file sphinx-warnings.txt" html
7070
- name: 'Check warnings'
7171
if: github.event_name == 'pull_request'
7272
run: |
@@ -101,4 +101,4 @@ jobs:
101101
run: make -C Doc/ PYTHON=../python venv
102102
# Use "xvfb-run" since some doctest tests open GUI windows
103103
- name: 'Run documentation doctest'
104-
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXERRORHANDLING="--fail-on-warning --keep-going" doctest
104+
run: xvfb-run make -C Doc/ PYTHON=../python SPHINXERRORHANDLING="--fail-on-warning" doctest

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,12 @@ Tools/unicode/data/
138138
# hendrikmuhs/ccache-action@v1
139139
/.ccache
140140
/cross-build/
141-
/jit_stencils.h
141+
/jit_stencils*.h
142142
/platform
143143
/profile-clean-stamp
144144
/profile-run-stamp
145145
/profile-bolt-stamp
146+
/profile-gen-stamp
146147
/pybuilddir.txt
147148
/pyconfig.h
148149
/python-config

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ Cautions regarding runtime finalization
11311131
In the late stage of :term:`interpreter shutdown`, after attempting to wait for
11321132
non-daemon threads to exit (though this can be interrupted by
11331133
:class:`KeyboardInterrupt`) and running the :mod:`atexit` functions, the runtime
1134-
is marked as *finalizing*: :c:func:`_Py_IsFinalizing` and
1134+
is marked as *finalizing*: :c:func:`Py_IsFinalizing` and
11351135
:func:`sys.is_finalizing` return true. At this point, only the *finalization
11361136
thread* that initiated finalization (typically the main thread) is allowed to
11371137
acquire the :term:`GIL`.
@@ -1517,16 +1517,6 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
15171517
.. versionadded:: 3.8
15181518
15191519
1520-
.. c:function:: PyObject* PyUnstable_InterpreterState_GetMainModule(PyInterpreterState *interp)
1521-
1522-
Return a :term:`strong reference` to the ``__main__`` :ref:`module object <moduleobjects>`
1523-
for the given interpreter.
1524-
1525-
The caller must have an :term:`attached thread state`.
1526-
1527-
.. versionadded:: 3.13
1528-
1529-
15301520
.. c:type:: PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
15311521
15321522
Type of a frame evaluation function.

Doc/c-api/unicode.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ Python:
3333

3434
.. c:var:: PyTypeObject PyUnicode_Type
3535
36-
This instance of :c:type:`PyTypeObject` represents the Python Unicode type. It
37-
is exposed to Python code as :py:class:`str`.
36+
This instance of :c:type:`PyTypeObject` represents the Python Unicode type.
37+
It is exposed to Python code as :py:class:`str`.
38+
39+
40+
.. c:var:: PyTypeObject PyUnicodeIter_Type
41+
42+
This instance of :c:type:`PyTypeObject` represents the Python Unicode
43+
iterator type. It is used to iterate over Unicode string objects.
3844

3945

4046
.. c:type:: Py_UCS4

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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ 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+
70+
* :mod:`mimetypes`:
71+
72+
* Valid extensions start with a '.' or are empty for
73+
:meth:`mimetypes.MimeTypes.add_type`.
74+
Undotted extensions are deprecated and will
75+
raise a :exc:`ValueError` in Python 3.16.
76+
(Contributed by Hugo van Kemenade in :gh:`75223`.)
77+
6478
* :mod:`shutil`:
6579

6680
* The :class:`!ExecError` exception
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/deprecations/pending-removal-in-future.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ although there is currently no date scheduled for their removal.
1313
deprecated.
1414
* The :class:`argparse.FileType` type converter is deprecated.
1515

16-
* :mod:`array`'s ``'u'`` format code (:gh:`57281`)
17-
1816
* :mod:`builtins`:
1917

2018
* ``bool(NotImplemented)``.
@@ -49,6 +47,8 @@ although there is currently no date scheduled for their removal.
4947
:data:`calendar.FEBRUARY`.
5048
(Contributed by Prince Roshan in :gh:`103636`.)
5149

50+
* :mod:`codecs`: use :func:`open` instead of :func:`codecs.open`. (:gh:`133038`)
51+
5252
* :attr:`codeobject.co_lnotab`: use the :meth:`codeobject.co_lines` method
5353
instead.
5454

Doc/howto/remote_debugging.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ file format structures from the binary file on disk. The ELF header contains a
110110
pointer to the section header table. Each section header contains metadata about
111111
a section including its name (stored in a separate string table), offset, and
112112
size. To find a specific section like .PyRuntime, you need to walk through these
113-
headers and match the section name. The section header then provdes the offset
113+
headers and match the section name. The section header then provides the offset
114114
where that section exists in the file, which can be used to calculate its
115115
runtime address when the binary is loaded into memory.
116116

Doc/library/ast.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,43 @@ Pattern matching
17611761

17621762
.. versionadded:: 3.10
17631763

1764+
1765+
Type annotations
1766+
^^^^^^^^^^^^^^^^
1767+
1768+
.. class:: TypeIgnore(lineno, tag)
1769+
1770+
A ``# type: ignore`` comment located at *lineno*.
1771+
*tag* is the optional tag specified by the form ``# type: ignore <tag>``.
1772+
1773+
.. doctest::
1774+
1775+
>>> print(ast.dump(ast.parse('x = 1 # type: ignore', type_comments=True), indent=4))
1776+
Module(
1777+
body=[
1778+
Assign(
1779+
targets=[
1780+
Name(id='x', ctx=Store())],
1781+
value=Constant(value=1))],
1782+
type_ignores=[
1783+
TypeIgnore(lineno=1, tag='')])
1784+
>>> print(ast.dump(ast.parse('x: bool = 1 # type: ignore[assignment]', type_comments=True), indent=4))
1785+
Module(
1786+
body=[
1787+
AnnAssign(
1788+
target=Name(id='x', ctx=Store()),
1789+
annotation=Name(id='bool', ctx=Load()),
1790+
value=Constant(value=1),
1791+
simple=1)],
1792+
type_ignores=[
1793+
TypeIgnore(lineno=1, tag='[assignment]')])
1794+
1795+
.. note::
1796+
:class:`!TypeIgnore` nodes are not generated when the *type_comments* parameter
1797+
is set to ``False`` (default). See :func:`ast.parse` for more details.
1798+
1799+
.. versionadded:: 3.8
1800+
17641801
.. _ast-type-params:
17651802

17661803
Type parameters

Doc/library/codecs.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ wider range of codecs when working with binary files:
208208
.. versionchanged:: 3.11
209209
The ``'U'`` mode has been removed.
210210

211+
.. deprecated:: next
212+
213+
:func:`codecs.open` has been superseded by :func:`open`.
214+
211215

212216
.. function:: EncodedFile(file, data_encoding, file_encoding=None, errors='strict')
213217

0 commit comments

Comments
 (0)