Skip to content

Commit ab0b101

Browse files
authored
Merge branch 'main' into move-codegen-optimization
2 parents 329d158 + 5ab9604 commit ab0b101

File tree

109 files changed

+897
-406
lines changed

Some content is hidden

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

109 files changed

+897
-406
lines changed

.github/workflows/build.yml

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -512,26 +512,59 @@ jobs:
512512
run: xvfb-run make ci
513513

514514
build_tsan:
515-
name: 'Thread sanitizer'
515+
name: >-
516+
Thread sanitizer
517+
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
516518
needs: check_source
517519
if: needs.check_source.outputs.run_tests == 'true'
520+
strategy:
521+
matrix:
522+
free-threading:
523+
- false
524+
- true
518525
uses: ./.github/workflows/reusable-tsan.yml
519526
with:
520527
config_hash: ${{ needs.check_source.outputs.config_hash }}
521-
options: ./configure --config-cache --with-thread-sanitizer --with-pydebug
522-
suppressions_path: Tools/tsan/supressions.txt
523-
tsan_logs_artifact_name: tsan-logs-default
528+
free-threading: ${{ matrix.free-threading }}
524529

525-
build_tsan_free_threading:
526-
name: 'Thread sanitizer (free-threading)'
530+
cross-build-linux:
531+
name: Cross build Linux
532+
runs-on: ubuntu-latest
527533
needs: check_source
528534
if: needs.check_source.outputs.run_tests == 'true'
529-
uses: ./.github/workflows/reusable-tsan.yml
530-
with:
531-
config_hash: ${{ needs.check_source.outputs.config_hash }}
532-
options: ./configure --config-cache --disable-gil --with-thread-sanitizer --with-pydebug
533-
suppressions_path: Tools/tsan/suppressions_free_threading.txt
534-
tsan_logs_artifact_name: tsan-logs-free-threading
535+
steps:
536+
- uses: actions/checkout@v4
537+
with:
538+
persist-credentials: false
539+
- name: Runner image version
540+
run: echo "IMAGE_VERSION=${ImageVersion}" >> "$GITHUB_ENV"
541+
- name: Restore config.cache
542+
uses: actions/cache@v4
543+
with:
544+
path: config.cache
545+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}
546+
- name: Register gcc problem matcher
547+
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
548+
- name: Set build dir
549+
run:
550+
# an absolute path outside of the working directoy
551+
echo "BUILD_DIR=$(realpath ${{ github.workspace }}/../build)" >> "$GITHUB_ENV"
552+
- name: Install Dependencies
553+
run: sudo ./.github/workflows/posix-deps-apt.sh
554+
- name: Configure host build
555+
run: ./configure --prefix="$BUILD_DIR/host-python"
556+
- name: Install host Python
557+
run: make -j8 install
558+
- name: Run test subset with host build
559+
run: |
560+
"$BUILD_DIR/host-python/bin/python3" -m test test_sysconfig test_site test_embed
561+
- name: Configure cross build
562+
run: ./configure --prefix="$BUILD_DIR/cross-python" --with-build-python="$BUILD_DIR/host-python/bin/python3"
563+
- name: Install cross Python
564+
run: make -j8 install
565+
- name: Run test subset with host build
566+
run: |
567+
"$BUILD_DIR/cross-python/bin/python3" -m test test_sysconfig test_site test_embed
535568
536569
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
537570
cifuzz:
@@ -591,7 +624,6 @@ jobs:
591624
- test_hypothesis
592625
- build_asan
593626
- build_tsan
594-
- build_tsan_free_threading
595627
- cifuzz
596628

597629
runs-on: ubuntu-latest
@@ -625,7 +657,6 @@ jobs:
625657
build_windows,
626658
build_asan,
627659
build_tsan,
628-
build_tsan_free_threading,
629660
'
630661
|| ''
631662
}}

.github/workflows/reusable-tsan.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,11 @@ on:
66
config_hash:
77
required: true
88
type: string
9-
options:
10-
required: true
11-
type: string
12-
suppressions_path:
13-
description: 'A repo relative path to the suppressions file'
14-
required: true
15-
type: string
16-
tsan_logs_artifact_name:
17-
description: 'Name of the TSAN logs artifact. Must be unique for each job.'
18-
required: true
19-
type: string
9+
free-threading:
10+
description: Whether to use free-threaded mode
11+
required: false
12+
type: boolean
13+
default: false
2014

2115
env:
2216
FORCE_COLOR: 1
@@ -26,9 +20,6 @@ jobs:
2620
name: 'Thread sanitizer'
2721
runs-on: ubuntu-24.04
2822
timeout-minutes: 60
29-
env:
30-
OPTIONS: ${{ inputs.options }}
31-
SUPPRESSIONS_PATH: ${{ inputs.suppressions_path }}
3223
steps:
3324
- uses: actions/checkout@v4
3425
with:
@@ -55,7 +46,11 @@ jobs:
5546
sudo sysctl -w vm.mmap_rnd_bits=28
5647
- name: TSAN Option Setup
5748
run: |
58-
echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/${SUPPRESSIONS_PATH} handle_segv=0" >> "$GITHUB_ENV"
49+
echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/Tools/tsan/suppressions${{
50+
fromJSON(inputs.free-threading)
51+
&& '_free_threading'
52+
|| ''
53+
}}.txt handle_segv=0" >> "$GITHUB_ENV"
5954
echo "CC=clang" >> "$GITHUB_ENV"
6055
echo "CXX=clang++" >> "$GITHUB_ENV"
6156
- name: Add ccache to PATH
@@ -67,7 +62,12 @@ jobs:
6762
save: ${{ github.event_name == 'push' }}
6863
max-size: "200M"
6964
- name: Configure CPython
70-
run: "${OPTIONS}"
65+
run: >-
66+
./configure
67+
--config-cache
68+
--with-thread-sanitizer
69+
--with-pydebug
70+
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
7171
- name: Build CPython
7272
run: make -j4
7373
- name: Display build info
@@ -81,6 +81,11 @@ jobs:
8181
if: always()
8282
uses: actions/upload-artifact@v4
8383
with:
84-
name: ${{ inputs.tsan_logs_artifact_name }}
84+
name: >-
85+
tsan-logs-${{
86+
fromJSON(inputs.free-threading)
87+
&& 'free-threading'
88+
|| 'default'
89+
}}
8590
path: tsan_log.*
8691
if-no-files-found: ignore

.github/workflows/reusable-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ env:
2424
2525
jobs:
2626
build:
27-
name: 'build and test (${{ inputs.arch }})'
27+
name: ${{ inputs.arch == 'arm64' && 'build' || 'build and test' }} (${{ inputs.arch }})
2828
runs-on: ${{ inputs.os }}
2929
timeout-minutes: 60
3030
env:

Doc/c-api/import.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,24 @@ Importing Modules
325325
If Python is initialized multiple times, :c:func:`PyImport_AppendInittab` or
326326
:c:func:`PyImport_ExtendInittab` must be called before each Python
327327
initialization.
328+
329+
330+
.. c:function:: PyObject* PyImport_ImportModuleAttr(PyObject *mod_name, PyObject *attr_name)
331+
332+
Import the module *mod_name* and get its attribute *attr_name*.
333+
334+
Names must be Python :class:`str` objects.
335+
336+
Helper function combining :c:func:`PyImport_Import` and
337+
:c:func:`PyObject_GetAttr`. For example, it can raise :exc:`ImportError` if
338+
the module is not found, and :exc:`AttributeError` if the attribute doesn't
339+
exist.
340+
341+
.. versionadded:: 3.14
342+
343+
.. c:function:: PyObject* PyImport_ImportModuleAttrString(const char *mod_name, const char *attr_name)
344+
345+
Similar to :c:func:`PyImport_ImportModuleAttr`, but names are UTF-8 encoded
346+
strings instead of Python :class:`str` objects.
347+
348+
.. versionadded:: 3.14

Doc/data/refcounts.dat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3052,3 +3052,11 @@ _Py_c_quot:Py_complex:divisor::
30523052
_Py_c_sum:Py_complex:::
30533053
_Py_c_sum:Py_complex:left::
30543054
_Py_c_sum:Py_complex:right::
3055+
3056+
PyImport_ImportModuleAttr:PyObject*::+1:
3057+
PyImport_ImportModuleAttr:PyObject*:mod_name:0:
3058+
PyImport_ImportModuleAttr:PyObject*:attr_name:0:
3059+
3060+
PyImport_ImportModuleAttrString:PyObject*::+1:
3061+
PyImport_ImportModuleAttrString:const char *:mod_name::
3062+
PyImport_ImportModuleAttrString:const char *:attr_name::

Doc/library/logging.handlers.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ The :class:`SysLogHandler` class, located in the :mod:`logging.handlers` module,
613613
supports sending logging messages to a remote or local Unix syslog.
614614

615615

616-
.. class:: SysLogHandler(address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER, socktype=socket.SOCK_DGRAM)
616+
.. class:: SysLogHandler(address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER, socktype=socket.SOCK_DGRAM, timeout=None)
617617

618618
Returns a new instance of the :class:`SysLogHandler` class intended to
619619
communicate with a remote Unix machine whose address is given by *address* in
@@ -626,6 +626,11 @@ supports sending logging messages to a remote or local Unix syslog.
626626
*socktype* argument, which defaults to :const:`socket.SOCK_DGRAM` and thus
627627
opens a UDP socket. To open a TCP socket (for use with the newer syslog
628628
daemons such as rsyslog), specify a value of :const:`socket.SOCK_STREAM`.
629+
If *timeout* is specified, it sets a timeout (in seconds) for the socket operations.
630+
This can help prevent the program from hanging indefinitely if the syslog server is
631+
unreachable. By default, *timeout* is ``None``, meaning no timeout is applied.
632+
633+
629634

630635
Note that if your server is not listening on UDP port 514,
631636
:class:`SysLogHandler` may appear not to work. In that case, check what
@@ -645,6 +650,8 @@ supports sending logging messages to a remote or local Unix syslog.
645650
.. versionchanged:: 3.2
646651
*socktype* was added.
647652

653+
.. versionchanged:: 3.14
654+
*timeout* was added.
648655

649656
.. method:: close()
650657

Doc/using/configure.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ General Options
311311

312312
By convention, ``--enable-experimental-jit`` is a shorthand for ``--enable-experimental-jit=yes``.
313313

314+
.. note::
315+
316+
When building CPython with JIT enabled, ensure that your system has Python 3.11 or later installed.
317+
314318
.. versionadded:: 3.13
315319

316320
.. option:: PKG_CONFIG

Doc/whatsnew/3.14.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,11 @@ New features
13221322
* Add :c:func:`PyUnstable_IsImmortal` for determining whether an object is :term:`immortal`,
13231323
for debugging purposes.
13241324

1325+
* Add :c:func:`PyImport_ImportModuleAttr` and
1326+
:c:func:`PyImport_ImportModuleAttrString` helper functions to import a module
1327+
and get an attribute of the module.
1328+
(Contributed by Victor Stinner in :gh:`128911`.)
1329+
13251330

13261331
Limited C API changes
13271332
---------------------

Include/cpython/import.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,10 @@ struct _frozen {
2121
collection of frozen modules: */
2222

2323
PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
24+
25+
PyAPI_FUNC(PyObject*) PyImport_ImportModuleAttr(
26+
PyObject *mod_name,
27+
PyObject *attr_name);
28+
PyAPI_FUNC(PyObject*) PyImport_ImportModuleAttrString(
29+
const char *mod_name,
30+
const char *attr_name);

Include/cpython/longintrepr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ typedef long stwodigits; /* signed variant of twodigits */
7676
- 1: Zero
7777
- 2: Negative
7878
79-
The third lowest bit of lv_tag is reserved for an immortality flag, but is
80-
not currently used.
79+
The third lowest bit of lv_tag is
80+
set to 1 for the small ints.
8181
8282
In a normalized number, ob_digit[ndigits-1] (the most significant
8383
digit) is never zero. Also, in all cases, for all valid i,

0 commit comments

Comments
 (0)