Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into disable-interpreter…
Browse files Browse the repository at this point in the history
…-optimizations-when-jit-enabled
  • Loading branch information
mdboom committed Oct 15, 2024
2 parents 8603b92 + c8a1818 commit bfcfe72
Show file tree
Hide file tree
Showing 201 changed files with 3,589 additions and 1,912 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,5 @@ Lib/test/test_configparser.py @jaraco

# Doc sections
Doc/reference/ @willingc

**/*weakref* @kumaraditya303
4 changes: 1 addition & 3 deletions .github/workflows/reusable-change-detection.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---

name: Change detection
name: Reusable change detection

on: # yamllint disable-line rule:truthy
workflow_call:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable-docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docs
name: Reusable Docs

on:
workflow_call:
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
doctest:
name: 'Doctest'
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-macos.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Reusable macOS

on:
workflow_call:
inputs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-tsan.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Reusable Thread Sanitizer

on:
workflow_call:
inputs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Reusable Ubuntu

on:
workflow_call:
inputs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-wasi.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Reusable WASI

on:
workflow_call:
inputs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-windows-msi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: TestsMSI
name: Reusable Windows MSI

on:
workflow_call:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reusable-windows.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Reusable Windows

on:
workflow_call:
inputs:
Expand Down
16 changes: 8 additions & 8 deletions Doc/c-api/contextvars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ Context object management functions:
.. c:type:: PyContextEvent
Enumeration of possible context object watcher events:
- ``Py_CONTEXT_EVENT_ENTER``
- ``Py_CONTEXT_EVENT_EXIT``
- ``Py_CONTEXT_SWITCHED``: The :term:`current context` has switched to a
different context. The object passed to the watch callback is the
now-current :class:`contextvars.Context` object, or None if no context is
current.
.. versionadded:: 3.14
.. c:type:: int (*PyContext_WatchCallback)(PyContextEvent event, PyContext* ctx)
.. c:type:: int (*PyContext_WatchCallback)(PyContextEvent event, PyObject *obj)
Type of a context object watcher callback function.
If *event* is ``Py_CONTEXT_EVENT_ENTER``, then the callback is invoked
after *ctx* has been set as the current context for the current thread.
Otherwise, the callback is invoked before the deactivation of *ctx* as the current context
and the restoration of the previous contex object for the current thread.
Context object watcher callback function. The object passed to the callback
is event-specific; see :c:type:`PyContextEvent` for details.
If the callback returns with an exception set, it must return ``-1``; this
exception will be printed as an unraisable exception using
Expand Down
18 changes: 12 additions & 6 deletions Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,8 @@ Create Config
Free memory of the initialization configuration *config*.
If *config* is ``NULL``, no operation is performed.
Error Handling
--------------
Expand Down Expand Up @@ -1823,14 +1825,18 @@ return ``-1`` on error:
PyInitConfig_Free(config);
return 0;
// Display the error message
const char *err_msg;
error:
(void)PyInitConfig_GetError(config, &err_msg);
printf("PYTHON INIT ERROR: %s\n", err_msg);
PyInitConfig_Free(config);
{
// Display the error message
// This uncommon braces style is used, because you cannot make
// goto targets point to variable declarations.
const char *err_msg;
(void)PyInitConfig_GetError(config, &err_msg);
printf("PYTHON INIT ERROR: %s\n", err_msg);
PyInitConfig_Free(config);
return -1;
return -1;
}
}
Expand Down
5 changes: 5 additions & 0 deletions Doc/c-api/long.rst
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
Exactly what values are considered compact is an implementation detail
and is subject to change.
.. versionadded:: 3.12
.. c:function:: Py_ssize_t PyUnstable_Long_CompactValue(const PyLongObject* op)
If *op* is compact, as determined by :c:func:`PyUnstable_Long_IsCompact`,
return its value.
Otherwise, the return value is undefined.
.. versionadded:: 3.12
2 changes: 2 additions & 0 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,8 @@ object.
Discard the internal Unicode buffer and destroy the writer instance.
If *writer* is ``NULL``, no operation is performed.
.. c:function:: int PyUnicodeWriter_WriteChar(PyUnicodeWriter *writer, Py_UCS4 ch)
Write the single Unicode character *ch* into *writer*.
Expand Down
31 changes: 24 additions & 7 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import sys
import time

import sphinx

sys.path.append(os.path.abspath('tools/extensions'))
sys.path.append(os.path.abspath('includes'))

Expand Down Expand Up @@ -62,7 +64,10 @@

# General substitutions.
project = 'Python'
copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation"
if sphinx.version_info[:2] >= (8, 1):
copyright = "2001-%Y, Python Software Foundation"
else:
copyright = f"2001-{time.strftime('%Y')}, Python Software Foundation"

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

# This 'Last updated on:' timestamp is inserted at the bottom of every page.
html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
html_last_updated_fmt = time.strftime(
'%b %d, %Y (%H:%M UTC)', time.gmtime(html_time)
)
html_last_updated_fmt = '%b %d, %Y (%H:%M UTC)'
if sphinx.version_info[:2] >= (8, 1):
html_last_updated_use_utc = True
else:
html_time = int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))
html_last_updated_fmt = time.strftime(
html_last_updated_fmt, time.gmtime(html_time)
)

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

if sphinx.version_info[:2] < (8, 1):
# Sphinx 8.1 has in-built CVE and CWE roles.
extlinks |= {
"cve": (
"https://www.cve.org/CVERecord?id=CVE-%s",
"CVE-%s",
),
"cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"),
}

# Options for c_annotations
# -------------------------

Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/c-api-pending-removal-in-3.14.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pending Removal in Python 3.14
Pending removal in Python 3.14
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* The ``ma_version_tag`` field in :c:type:`PyDictObject` for extension modules
Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/c-api-pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pending Removal in Python 3.15
Pending removal in Python 3.15
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* The bundled copy of ``libmpdecimal``.
Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/c-api-pending-removal-in-future.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pending Removal in Future Versions
Pending removal in future versions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The following APIs are deprecated and will be removed,
Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Deprecations

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

C API Deprecations
C API deprecations
------------------

.. include:: c-api-pending-removal-in-3.15.rst
Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/pending-removal-in-3.13.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pending Removal in Python 3.13
Pending removal in Python 3.13
------------------------------

Modules (see :pep:`594`):
Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/pending-removal-in-3.14.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pending Removal in Python 3.14
Pending removal in Python 3.14
------------------------------

* The import system:
Expand Down
4 changes: 2 additions & 2 deletions Doc/deprecations/pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pending Removal in Python 3.15
Pending removal in Python 3.15
------------------------------

* The import system:
Expand Down Expand Up @@ -63,7 +63,7 @@ Pending Removal in Python 3.15

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

Expand Down
29 changes: 14 additions & 15 deletions Doc/deprecations/pending-removal-in-3.16.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
Pending Removal in Python 3.16
Pending removal in Python 3.16
------------------------------

* :mod:`builtins`:

* Bitwise inversion on boolean types, ``~True`` or ``~False``
has been deprecated since Python 3.12,
as it produces surprising and unintuitive results (``-2`` and ``-1``).
Use ``not x`` instead for the logical negation of a Boolean.
In the rare case that you need the bitwise inversion of
the underlying integer, convert to ``int`` explicitly (``~int(x)``).

* :mod:`array`:

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

* :mod:`asyncio`:

* :mod:`asyncio`:
:func:`!asyncio.iscoroutinefunction` is deprecated
and will be removed in Python 3.16,
use :func:`inspect.iscoroutinefunction` instead.
(Contributed by Jiahao Li and Kumar Aditya in :gh:`122875`.)
* :func:`!asyncio.iscoroutinefunction` is deprecated
and will be removed in Python 3.16,
use :func:`inspect.iscoroutinefunction` instead.
(Contributed by Jiahao Li and Kumar Aditya in :gh:`122875`.)

* :mod:`builtins`:

* Bitwise inversion on boolean types, ``~True`` or ``~False``
has been deprecated since Python 3.12,
as it produces surprising and unintuitive results (``-2`` and ``-1``).
Use ``not x`` instead for the logical negation of a Boolean.
In the rare case that you need the bitwise inversion of
the underlying integer, convert to ``int`` explicitly (``~int(x)``).

* :mod:`shutil`:

Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/pending-removal-in-future.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pending Removal in Future Versions
Pending removal in future versions
----------------------------------

The following APIs will be removed in the future,
Expand Down
42 changes: 32 additions & 10 deletions Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,19 +265,33 @@ Glossary
advanced mathematical feature. If you're not aware of a need for them,
it's almost certain you can safely ignore them.

context
This term has different meanings depending on where and how it is used.
Some common meanings:

* The temporary state or environment established by a :term:`context
manager` via a :keyword:`with` statement.
* The collection of key­value bindings associated with a particular
:class:`contextvars.Context` object and accessed via
:class:`~contextvars.ContextVar` objects. Also see :term:`context
variable`.
* A :class:`contextvars.Context` object. Also see :term:`current
context`.

context management protocol
The :meth:`~object.__enter__` and :meth:`~object.__exit__` methods called
by the :keyword:`with` statement. See :pep:`343`.

context manager
An object which controls the environment seen in a :keyword:`with`
statement by defining :meth:`~object.__enter__` and :meth:`~object.__exit__` methods.
See :pep:`343`.
An object which implements the :term:`context management protocol` and
controls the environment seen in a :keyword:`with` statement. See
:pep:`343`.

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

contiguous
.. index:: C-contiguous, Fortran contiguous
Expand Down Expand Up @@ -311,6 +325,14 @@ Glossary
is used when necessary to distinguish this implementation from others
such as Jython or IronPython.

current context
The :term:`context` (:class:`contextvars.Context` object) that is
currently used by :class:`~contextvars.ContextVar` objects to access (get
or set) the values of :term:`context variables <context variable>`. Each
thread has its own current context. Frameworks for executing asynchronous
tasks (see :mod:`asyncio`) associate each task with a context which
becomes the current context whenever the task starts or resumes execution.

decorator
A function returning another function, usually applied as a function
transformation using the ``@wrapper`` syntax. Common examples for
Expand Down Expand Up @@ -595,7 +617,7 @@ Glossary

As of Python 3.13, the GIL can be disabled using the :option:`--disable-gil`
build configuration. After building Python with this option, code must be
run with :option:`-X gil 0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 <PYTHON_GIL>`
run with :option:`-X gil=0 <-X>` or after setting the :envvar:`PYTHON_GIL=0 <PYTHON_GIL>`
environment variable. This feature enables improved performance for
multi-threaded applications and makes it easier to use multi-core CPUs
efficiently. For more details, see :pep:`703`.
Expand Down
8 changes: 5 additions & 3 deletions Doc/library/_thread.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,11 @@ In addition to these methods, lock objects can also be used via the
* Calling :func:`sys.exit` or raising the :exc:`SystemExit` exception is
equivalent to calling :func:`_thread.exit`.

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

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

0 comments on commit bfcfe72

Please sign in to comment.