Skip to content

Commit bfcfe72

Browse files
committed
Merge remote-tracking branch 'upstream/main' into disable-interpreter-optimizations-when-jit-enabled
2 parents 8603b92 + c8a1818 commit bfcfe72

File tree

201 files changed

+3589
-1912
lines changed

Some content is hidden

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

201 files changed

+3589
-1912
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,5 @@ Lib/test/test_configparser.py @jaraco
280280

281281
# Doc sections
282282
Doc/reference/ @willingc
283+
284+
**/*weakref* @kumaraditya303

.github/workflows/reusable-change-detection.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
---
2-
3-
name: Change detection
1+
name: Reusable change detection
42

53
on: # yamllint disable-line rule:truthy
64
workflow_call:

.github/workflows/reusable-docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docs
1+
name: Reusable Docs
22

33
on:
44
workflow_call:
@@ -95,7 +95,7 @@ jobs:
9595
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
9696
doctest:
9797
name: 'Doctest'
98-
runs-on: ubuntu-latest
98+
runs-on: ubuntu-22.04
9999
timeout-minutes: 60
100100
steps:
101101
- uses: actions/checkout@v4

.github/workflows/reusable-macos.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Reusable macOS
2+
13
on:
24
workflow_call:
35
inputs:

.github/workflows/reusable-tsan.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Reusable Thread Sanitizer
2+
13
on:
24
workflow_call:
35
inputs:

.github/workflows/reusable-ubuntu.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Reusable Ubuntu
2+
13
on:
24
workflow_call:
35
inputs:

.github/workflows/reusable-wasi.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Reusable WASI
2+
13
on:
24
workflow_call:
35
inputs:

.github/workflows/reusable-windows-msi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: TestsMSI
1+
name: Reusable Windows MSI
22

33
on:
44
workflow_call:

.github/workflows/reusable-windows.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Reusable Windows
2+
13
on:
24
workflow_call:
35
inputs:

Doc/c-api/contextvars.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,18 @@ Context object management functions:
122122
.. c:type:: PyContextEvent
123123
124124
Enumeration of possible context object watcher events:
125-
- ``Py_CONTEXT_EVENT_ENTER``
126-
- ``Py_CONTEXT_EVENT_EXIT``
125+
126+
- ``Py_CONTEXT_SWITCHED``: The :term:`current context` has switched to a
127+
different context. The object passed to the watch callback is the
128+
now-current :class:`contextvars.Context` object, or None if no context is
129+
current.
127130
128131
.. versionadded:: 3.14
129132
130-
.. c:type:: int (*PyContext_WatchCallback)(PyContextEvent event, PyContext* ctx)
133+
.. c:type:: int (*PyContext_WatchCallback)(PyContextEvent event, PyObject *obj)
131134
132-
Type of a context object watcher callback function.
133-
If *event* is ``Py_CONTEXT_EVENT_ENTER``, then the callback is invoked
134-
after *ctx* has been set as the current context for the current thread.
135-
Otherwise, the callback is invoked before the deactivation of *ctx* as the current context
136-
and the restoration of the previous contex object for the current thread.
135+
Context object watcher callback function. The object passed to the callback
136+
is event-specific; see :c:type:`PyContextEvent` for details.
137137
138138
If the callback returns with an exception set, it must return ``-1``; this
139139
exception will be printed as an unraisable exception using

Doc/c-api/init_config.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,8 @@ Create Config
16211621
16221622
Free memory of the initialization configuration *config*.
16231623
1624+
If *config* is ``NULL``, no operation is performed.
1625+
16241626
16251627
Error Handling
16261628
--------------
@@ -1823,14 +1825,18 @@ return ``-1`` on error:
18231825
PyInitConfig_Free(config);
18241826
return 0;
18251827
1826-
// Display the error message
1827-
const char *err_msg;
18281828
error:
1829-
(void)PyInitConfig_GetError(config, &err_msg);
1830-
printf("PYTHON INIT ERROR: %s\n", err_msg);
1831-
PyInitConfig_Free(config);
1829+
{
1830+
// Display the error message
1831+
// This uncommon braces style is used, because you cannot make
1832+
// goto targets point to variable declarations.
1833+
const char *err_msg;
1834+
(void)PyInitConfig_GetError(config, &err_msg);
1835+
printf("PYTHON INIT ERROR: %s\n", err_msg);
1836+
PyInitConfig_Free(config);
18321837
1833-
return -1;
1838+
return -1;
1839+
}
18341840
}
18351841
18361842

Doc/c-api/long.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
608608
Exactly what values are considered compact is an implementation detail
609609
and is subject to change.
610610
611+
.. versionadded:: 3.12
612+
613+
611614
.. c:function:: Py_ssize_t PyUnstable_Long_CompactValue(const PyLongObject* op)
612615
613616
If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`,
614617
return its value.
615618
616619
Otherwise, the return value is undefined.
617620
621+
.. versionadded:: 3.12
622+

Doc/c-api/unicode.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,8 @@ object.
16001600
16011601
Discard the internal Unicode buffer and destroy the writer instance.
16021602
1603+
If *writer* is ``NULL``, no operation is performed.
1604+
16031605
.. c:function:: int PyUnicodeWriter_WriteChar(PyUnicodeWriter *writer, Py_UCS4 ch)
16041606
16051607
Write the single Unicode character *ch* into *writer*.

Doc/conf.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import sys
1212
import time
1313

14+
import sphinx
15+
1416
sys.path.append(os.path.abspath('tools/extensions'))
1517
sys.path.append(os.path.abspath('includes'))
1618

@@ -62,7 +64,10 @@
6264

6365
# General substitutions.
6466
project = 'Python'
65-
copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation"
67+
if sphinx.version_info[:2] >= (8, 1):
68+
copyright = "2001-%Y, Python Software Foundation"
69+
else:
70+
copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation"
6671

6772
# We look for the Include/patchlevel.h file in the current Python source tree
6873
# and replace the values accordingly.
@@ -361,10 +366,14 @@
361366
}
362367

363368
# This 'Last updated on:' timestamp is inserted at the bottom of every page.
364-
html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
365-
html_last_updated_fmt = time.strftime(
366-
'%b %d, %Y (%H:%M UTC)', time.gmtime(html_time)
367-
)
369+
html_last_updated_fmt = '%b %d, %Y (%H:%M UTC)'
370+
if sphinx.version_info[:2] >= (8, 1):
371+
html_last_updated_use_utc = True
372+
else:
373+
html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
374+
html_last_updated_fmt = time.strftime(
375+
html_last_updated_fmt, time.gmtime(html_time)
376+
)
368377

369378
# Path to find HTML templates.
370379
templates_path = ['tools/templates']
@@ -596,13 +605,21 @@
596605
# mapping unique short aliases to a base URL and a prefix.
597606
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
598607
extlinks = {
599-
"cve": ("https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s", "CVE-%s"),
600-
"cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"),
601608
"pypi": ("https://pypi.org/project/%s/", "%s"),
602609
"source": (SOURCE_URI, "%s"),
603610
}
604611
extlinks_detect_hardcoded_links = True
605612

613+
if sphinx.version_info[:2] < (8, 1):
614+
# Sphinx 8.1 has in-built CVE and CWE roles.
615+
extlinks |= {
616+
"cve": (
617+
"https://www.cve.org/CVERecord?id=CVE-%s",
618+
"CVE-%s",
619+
),
620+
"cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"),
621+
}
622+
606623
# Options for c_annotations
607624
# -------------------------
608625

Doc/deprecations/c-api-pending-removal-in-3.14.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Pending Removal in Python 3.14
1+
Pending removal in Python 3.14
22
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33

44
* The ``ma_version_tag`` field in :c:type:`PyDictObject` for extension modules

Doc/deprecations/c-api-pending-removal-in-3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Pending Removal in Python 3.15
1+
Pending removal in Python 3.15
22
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33

44
* The bundled copy of ``libmpdecimal``.

Doc/deprecations/c-api-pending-removal-in-future.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Pending Removal in Future Versions
1+
Pending removal in future versions
22
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33

44
The following APIs are deprecated and will be removed,

Doc/deprecations/index.rst

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

88
.. include:: pending-removal-in-future.rst
99

10-
C API Deprecations
10+
C API deprecations
1111
------------------
1212

1313
.. include:: c-api-pending-removal-in-3.15.rst

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Pending Removal in Python 3.13
1+
Pending removal in Python 3.13
22
------------------------------
33

44
Modules (see :pep:`594`):

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Pending Removal in Python 3.14
1+
Pending removal in Python 3.14
22
------------------------------
33

44
* The import system:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Pending Removal in Python 3.15
1+
Pending removal in Python 3.15
22
------------------------------
33

44
* The import system:
@@ -63,7 +63,7 @@ Pending Removal in Python 3.15
6363

6464
* The undocumented keyword argument syntax for creating
6565
:class:`~typing.NamedTuple` classes
66-
(e.g. ``Point = NamedTuple("Point", x=int, y=int)``)
66+
(for example, ``Point = NamedTuple("Point", x=int, y=int)``)
6767
has been deprecated since Python 3.13.
6868
Use the class-based syntax or the functional syntax instead.
6969

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
Pending Removal in Python 3.16
1+
Pending removal in Python 3.16
22
------------------------------
33

4-
* :mod:`builtins`:
5-
6-
* Bitwise inversion on boolean types, ``~True`` or ``~False``
7-
has been deprecated since Python 3.12,
8-
as it produces surprising and unintuitive results (``-2`` and ``-1``).
9-
Use ``not x`` instead for the logical negation of a Boolean.
10-
In the rare case that you need the bitwise inversion of
11-
the underlying integer, convert to ``int`` explicitly (``~int(x)``).
12-
134
* :mod:`array`:
145

156
* The ``'u'`` format code (:c:type:`wchar_t`)
@@ -20,11 +11,19 @@ Pending Removal in Python 3.16
2011

2112
* :mod:`asyncio`:
2213

23-
* :mod:`asyncio`:
24-
:func:`!asyncio.iscoroutinefunction` is deprecated
25-
and will be removed in Python 3.16,
26-
use :func:`inspect.iscoroutinefunction` instead.
27-
(Contributed by Jiahao Li and Kumar Aditya in :gh:`122875`.)
14+
* :func:`!asyncio.iscoroutinefunction` is deprecated
15+
and will be removed in Python 3.16,
16+
use :func:`inspect.iscoroutinefunction` instead.
17+
(Contributed by Jiahao Li and Kumar Aditya in :gh:`122875`.)
18+
19+
* :mod:`builtins`:
20+
21+
* Bitwise inversion on boolean types, ``~True`` or ``~False``
22+
has been deprecated since Python 3.12,
23+
as it produces surprising and unintuitive results (``-2`` and ``-1``).
24+
Use ``not x`` instead for the logical negation of a Boolean.
25+
In the rare case that you need the bitwise inversion of
26+
the underlying integer, convert to ``int`` explicitly (``~int(x)``).
2827

2928
* :mod:`shutil`:
3029

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Pending Removal in Future Versions
1+
Pending removal in future versions
22
----------------------------------
33

44
The following APIs will be removed in the future,

Doc/glossary.rst

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,19 +265,33 @@ Glossary
265265
advanced mathematical feature. If you're not aware of a need for them,
266266
it's almost certain you can safely ignore them.
267267

268+
context
269+
This term has different meanings depending on where and how it is used.
270+
Some common meanings:
271+
272+
* The temporary state or environment established by a :term:`context
273+
manager` via a :keyword:`with` statement.
274+
* The collection of key­value bindings associated with a particular
275+
:class:`contextvars.Context` object and accessed via
276+
:class:`~contextvars.ContextVar` objects. Also see :term:`context
277+
variable`.
278+
* A :class:`contextvars.Context` object. Also see :term:`current
279+
context`.
280+
281+
context management protocol
282+
The :meth:`~object.__enter__` and :meth:`~object.__exit__` methods called
283+
by the :keyword:`with` statement. See :pep:`343`.
284+
268285
context manager
269-
An object which controls the environment seen in a :keyword:`with`
270-
statement by defining :meth:`~object.__enter__` and :meth:`~object.__exit__` methods.
271-
See :pep:`343`.
286+
An object which implements the :term:`context management protocol` and
287+
controls the environment seen in a :keyword:`with` statement. See
288+
:pep:`343`.
272289

273290
context variable
274-
A variable which can have different values depending on its context.
275-
This is similar to Thread-Local Storage in which each execution
276-
thread may have a different value for a variable. However, with context
277-
variables, there may be several contexts in one execution thread and the
278-
main usage for context variables is to keep track of variables in
291+
A variable whose value depends on which context is the :term:`current
292+
context`. Values are accessed via :class:`contextvars.ContextVar`
293+
objects. Context variables are primarily used to isolate state between
279294
concurrent asynchronous tasks.
280-
See :mod:`contextvars`.
281295

282296
contiguous
283297
.. index:: C-contiguous, Fortran contiguous
@@ -311,6 +325,14 @@ Glossary
311325
is used when necessary to distinguish this implementation from others
312326
such as Jython or IronPython.
313327

328+
current context
329+
The :term:`context` (:class:`contextvars.Context` object) that is
330+
currently used by :class:`~contextvars.ContextVar` objects to access (get
331+
or set) the values of :term:`context variables <context variable>`. Each
332+
thread has its own current context. Frameworks for executing asynchronous
333+
tasks (see :mod:`asyncio`) associate each task with a context which
334+
becomes the current context whenever the task starts or resumes execution.
335+
314336
decorator
315337
A function returning another function, usually applied as a function
316338
transformation using the ``@wrapper`` syntax. Common examples for
@@ -595,7 +617,7 @@ Glossary
595617

596618
As of Python 3.13, the GIL can be disabled using the :option:`--disable-gil`
597619
build configuration. After building Python with this option, code must be
598-
run with :option:`-X gil 0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 <PYTHON_GIL>`
620+
run with :option:`-X gil=0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 <PYTHON_GIL>`
599621
environment variable. This feature enables improved performance for
600622
multi-threaded applications and makes it easier to use multi-core CPUs
601623
efficiently. For more details, see :pep:`703`.

Doc/library/_thread.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,11 @@ In addition to these methods, lock objects can also be used via the
219219
* Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is
220220
equivalent to calling :func:`_thread.exit`.
221221

222-
* It is not possible to interrupt the :meth:`~threading.Lock.acquire` method on
223-
a lock --- the :exc:`KeyboardInterrupt` exception will happen after the lock
224-
has been acquired.
222+
* It is platform-dependent whether the :meth:`~threading.Lock.acquire` method
223+
on a lock can be interrupted (so that the :exc:`KeyboardInterrupt` exception
224+
will happen immediately, rather than only after the lock has been acquired or
225+
the operation has timed out). It can be interrupted on POSIX, but not on
226+
Windows.
225227

226228
* When the main thread exits, it is system defined whether the other threads
227229
survive. On most systems, they are killed without executing

0 commit comments

Comments
 (0)