Skip to content

Commit 374e182

Browse files
committed
Merge remote-tracking branch 'origin/main' into move-build-details-generation-to-sysconfig-updated
Signed-off-by: Filipe Laíns <lains@riseup.net>
2 parents 3a730ab + 9d6fa5d commit 374e182

559 files changed

Lines changed: 19787 additions & 6307 deletions

File tree

Some content is hidden

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

‎.github/workflows/build.yml‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,12 @@ jobs:
167167
- true
168168
interpreter:
169169
- switch-case
170+
- tail-call
170171
exclude:
171172
# Skip Win32 on free-threaded builds
172173
- { arch: Win32, free-threading: true }
173-
include:
174-
# msvc::musttail is currently only supported on x64,
175-
# and only supported on 3.15+.
176-
- { arch: x64, free-threading: false, interpreter: tail-call }
177-
- { arch: x64, free-threading: true, interpreter: tail-call }
174+
# Skip Win32 on tail-call interpreter builds
175+
- { arch: Win32, interpreter: tail-call }
178176
uses: $/.github/workflows/reusable-windows.yml
179177
with:
180178
arch: ${{ matrix.arch }}
@@ -549,9 +547,17 @@ jobs:
549547
run: |
550548
"$BUILD_DIR/host-python/bin/python3" -m test test_sysconfig test_site test_embed
551549
- name: Configure cross build
552-
run: ./configure --prefix="$BUILD_DIR/cross-python" --with-build-python="$BUILD_DIR/host-python/bin/python3"
550+
run: |
551+
# Exercise a native build whose builtin modules differ from the build Python.
552+
echo '_bisect _bisectmodule.c' > Modules/Setup.local
553+
./configure --prefix="$BUILD_DIR/cross-python" --with-build-python="$BUILD_DIR/host-python/bin/python3"
553554
- name: Install cross Python
554555
run: make -j8 install
556+
- name: Check native extension modules with a build Python
557+
run: |
558+
"$BUILD_DIR/host-python/bin/python3" -c "import sys; assert '_bisect' not in sys.builtin_module_names"
559+
"$BUILD_DIR/cross-python/bin/python3" -c "import _bisect, sys; assert '_bisect' in sys.builtin_module_names"
560+
PYTHONSTRICTEXTENSIONBUILD=1 make checksharedmods
555561
- name: Display build info
556562
run: |
557563
"$BUILD_DIR/cross-python/bin/python3" -m test.pythoninfo

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*.orig
1818
*.pyc
1919
*.pyd
20-
*.pyo
2120
*.rej
2221
*.swp
2322
*.pickle

‎Doc/builtins/functions.rst‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,11 @@ are always available. They are listed here in alphabetical order.
11811181
a :exc:`TypeError` exception is raised. :exc:`TypeError` may not be
11821182
raised for an invalid type if an earlier check succeeds.
11831183

1184+
If *object* has a ``__class__`` attribute that differs from
1185+
:func:`type(object) <type>` (for example a proxy, or a :mod:`unittest.mock`
1186+
object created with a *spec*), ``True`` is also returned when that class
1187+
is a subclass of *classinfo*.
1188+
11841189
.. versionchanged:: 3.10
11851190
*classinfo* can be a :ref:`types-union`.
11861191

@@ -2411,14 +2416,17 @@ are always available. They are listed here in alphabetical order.
24112416
This is an advanced function that is not needed in everyday Python
24122417
programming, unlike :func:`importlib.import_module`.
24132418

2414-
This function is invoked by the :keyword:`import` statement. It can be
2415-
replaced (by importing the :mod:`builtins` module and assigning to
2416-
``builtins.__import__``) in order to change semantics of the
2417-
:keyword:`!import` statement, but doing so is **strongly** discouraged as it
2418-
is usually simpler to use import hooks (see :pep:`302`) to attain the same
2419-
goals and does not cause issues with code which assumes the default import
2420-
implementation is in use. Direct use of :func:`__import__` is also
2421-
discouraged in favor of :func:`importlib.import_module`.
2419+
Eager :keyword:`import` statements call this function.
2420+
For :ref:`lazy imports <lazy-imports>`, Python calls this function at
2421+
resolution.
2422+
2423+
You can replace :func:`__import__` through an assignment to
2424+
``builtins.__import__``. :ref:`Import hooks <import-hooks>` usually provide a
2425+
simpler way to customize imports. A replacement can cause problems for code
2426+
that expects the default import implementation.
2427+
Do not replace :func:`__import__` unless import hooks cannot supply the
2428+
required behavior.
2429+
To import a module by name, use :func:`importlib.import_module`.
24222430

24232431
The function imports the module *name*, potentially using the given *globals*
24242432
and *locals* to determine how to interpret the name in a package context.

‎Doc/c-api/dict.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ Dictionary objects
526526
as an argument, prefer :c:func:`PyFrozenDict_New` to leave the source
527527
intact.
528528
529+
Does not work for dicts with embedded values.
530+
529531
.. impl-detail::
530532
531533
Works with O(1) complexity.

‎Doc/c-api/gcsupport.rst‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type:
253253
returned immediately.
254254
Otherwise, return zero.
255255
256+
The garbage collector can call :c:member:`~PyTypeObject.tp_traverse` more
257+
than once for the same object during a collection. If the object's
258+
references do not change, each traversal must visit the same references.
259+
In particular, do not skip a reference because a lock is busy.
260+
If one traversal visits a reference and a later traversal skips it, the
261+
collector can clear an object that is still reachable.
262+
256263
A typical :c:member:`!tp_traverse` function calls the :c:func:`Py_VISIT`
257264
convenience macro on each of the instance's members that are Python
258265
objects that the instance owns.
@@ -318,14 +325,6 @@ The :c:member:`~PyTypeObject.tp_traverse` handler must have the following type:
318325
For a list of safe functions, see a
319326
:ref:`separate section <duringgc-functions>` below.
320327
321-
If an error occurs during traversal, ignore it and return 0.
322-
If ``tp_traverse`` fails to visit some strong references, garbage reference
323-
cycles involving the skipped references will not be reliably broken,
324-
but correctness won't be affected.
325-
For example, if traversal requires a lock that cannot be acquired promptly,
326-
skip the traversal.
327-
The garbage collector will visit your object again in a future pass.
328-
329328
.. note::
330329
331330
The :c:func:`Py_VISIT` call may be skipped for those members that provably

‎Doc/c-api/import.rst‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,13 @@ Importing Modules
371371
372372
.. c:function:: int PyImport_SetLazyImportsFilter(PyObject *filter)
373373
374-
Sets the current lazy imports filter. The *filter* should be a callable that
375-
will receive ``(importing_module_name, imported_module_name, [fromlist])``
376-
when an import can potentially be lazy. The ``imported_module_name`` value
377-
is the resolved module name, so ``lazy from .spam import eggs`` passes
378-
``package.spam``. The callable must return ``True`` if the import should be
379-
lazy and ``False`` otherwise.
374+
Set the lazy import filter for the current interpreter.
375+
The *filter* must be a callable, ``NULL``, or :c:data:`Py_None`.
376+
Use ``NULL`` or :c:data:`Py_None` to clear the filter.
377+
The callable receives three positional arguments:
378+
``(importing_module_name, imported_module_name, fromlist)``.
379+
See :func:`sys.set_lazy_imports_filter` for the arguments and filter
380+
behavior.
380381
381382
Return ``0`` on success and ``-1`` with an exception set otherwise.
382383
@@ -388,11 +389,13 @@ Importing Modules
388389
389390
.. c:enumerator:: PyImport_LAZY_NORMAL
390391
391-
Respect the ``lazy`` keyword in source code. This is the default mode.
392+
Respect :keyword:`lazy` and :attr:`module.__lazy_modules__`.
393+
This is the default mode.
392394
393395
.. c:enumerator:: PyImport_LAZY_ALL
394396
395-
Make all imports lazy by default.
397+
Make eligible module-scope imports lazy by default.
398+
See the :ref:`lazy import restrictions <lazy-imports>`.
396399
397400
.. versionadded:: 3.15
398401

‎Doc/c-api/init_config.rst‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,9 +1607,11 @@ PyConfig
16071607
16081608
Control :ref:`lazy imports <lazy-imports>`.
16091609
1610-
A value of ``-1`` keeps the default behaviour, where only imports marked
1611-
with the ``lazy`` keyword are lazy. A value of ``1`` makes every import
1612-
lazy. ``0`` is rejected.
1610+
A value of ``-1`` selects the default behavior, which respects
1611+
:keyword:`lazy` and :attr:`module.__lazy_modules__`.
1612+
A value of ``1`` makes eligible module-scope imports lazy by default.
1613+
The :ref:`lazy import restrictions <lazy-imports>` apply in both modes.
1614+
A value of ``0`` is invalid.
16131615
16141616
Configured by the :option:`-X lazy_imports <-X>` command line option or
16151617
the :envvar:`PYTHON_LAZY_IMPORTS` environment variable.

‎Doc/c-api/intro.rst‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,6 @@ System includes
140140
* ``<stdio.h>``
141141
* ``<stdlib.h>``
142142

143-
.. note::
144-
145-
Since Python may define some pre-processor definitions which affect the standard
146-
headers on some systems, you *must* include :file:`Python.h` before any standard
147-
headers are included.
148-
149143

150144
Useful macros
151145
=============

‎Doc/c-api/stable.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ versions of Python, without recompilation.
6464

6565
For simplicity, this document talks about *extensions*, but Stable ABI
6666
works the same way for all uses of the API – for example, embedding Python.
67+
When embedding Python on Linux, see :ref:`embedding-python-versions`
68+
for how to link the application and for limitations.
6769

6870
There are two Stable ABIs:
6971

‎Doc/data/refcounts.dat‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,9 @@ PyType_GenericNew:PyObject*:type:0:
24172417
PyType_GenericNew:PyObject*:args:0:
24182418
PyType_GenericNew:PyObject*:kwds:0:
24192419

2420+
PyType_GetDict:PyObject*::+1:
2421+
PyType_GetDict:PyTypeObject*:type:0:
2422+
24202423
PyType_GetFlags:unsigned long:::
24212424
PyType_GetFlags:PyTypeObject*:type:0:
24222425

0 commit comments

Comments
 (0)