Skip to content

Commit 7fe53d8

Browse files
Merge remote-tracking branch 'upstream/main' into tail-call
2 parents f906c97 + 22b2d37 commit 7fe53d8

File tree

135 files changed

+1440
-570
lines changed

Some content is hidden

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

135 files changed

+1440
-570
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,45 @@ jobs:
527527
config_hash: ${{ needs.check_source.outputs.config_hash }}
528528
free-threading: ${{ matrix.free-threading }}
529529

530+
cross-build-linux:
531+
name: Cross build Linux
532+
runs-on: ubuntu-latest
533+
needs: check_source
534+
if: needs.check_source.outputs.run_tests == 'true'
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
568+
530569
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
531570
cifuzz:
532571
name: CIFuzz

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/library/sys.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only
14221422
AIX ``'aix'``
14231423
Android ``'android'``
14241424
Emscripten ``'emscripten'``
1425+
FreeBSD ``'freebsd'``
14251426
iOS ``'ios'``
14261427
Linux ``'linux'``
14271428
macOS ``'darwin'``
@@ -1432,12 +1433,12 @@ always available. Unless explicitly noted otherwise, all variables are read-only
14321433

14331434
On Unix systems not listed in the table, the value is the lowercased OS name
14341435
as returned by ``uname -s``, with the first part of the version as returned by
1435-
``uname -r`` appended, e.g. ``'sunos5'`` or ``'freebsd8'``, *at the time
1436-
when Python was built*. Unless you want to test for a specific system
1437-
version, it is therefore recommended to use the following idiom::
1436+
``uname -r`` appended, e.g. ``'sunos5'``, *at the time when Python was built*.
1437+
Unless you want to test for a specific system version, it is therefore
1438+
recommended to use the following idiom::
14381439

1439-
if sys.platform.startswith('freebsd'):
1440-
# FreeBSD-specific code here...
1440+
if sys.platform.startswith('sunos'):
1441+
# SunOS-specific code here...
14411442

14421443
.. versionchanged:: 3.3
14431444
On Linux, :data:`sys.platform` doesn't contain the major version anymore.
@@ -1451,6 +1452,10 @@ always available. Unless explicitly noted otherwise, all variables are read-only
14511452
On Android, :data:`sys.platform` now returns ``'android'`` rather than
14521453
``'linux'``.
14531454

1455+
.. versionchanged:: 3.14
1456+
On FreeBSD, :data:`sys.platform` doesn't contain the major version anymore.
1457+
It is always ``'freebsd'``, instead of ``'freebsd13'`` or ``'freebsd14'``.
1458+
14541459
.. seealso::
14551460

14561461
:data:`os.name` has a coarser granularity. :func:`os.uname` gives

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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,9 @@ sys
649649
which only exists in specialized builds of Python, may now return objects
650650
from other interpreters than the one it's called in.
651651

652+
* On FreeBSD, :data:`sys.platform` doesn't contain the major version anymore.
653+
It is always ``'freebsd'``, instead of ``'freebsd13'`` or ``'freebsd14'``.
654+
652655
sys.monitoring
653656
--------------
654657

@@ -1322,6 +1325,11 @@ New features
13221325
* Add :c:func:`PyUnstable_IsImmortal` for determining whether an object is :term:`immortal`,
13231326
for debugging purposes.
13241327

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

13261334
Limited C API changes
13271335
---------------------

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,

Include/cpython/pyatomic.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,15 +574,15 @@ static inline void _Py_atomic_fence_release(void);
574574

575575
#if _Py_USE_GCC_BUILTIN_ATOMICS
576576
# define Py_ATOMIC_GCC_H
577-
# include "cpython/pyatomic_gcc.h"
577+
# include "pyatomic_gcc.h"
578578
# undef Py_ATOMIC_GCC_H
579579
#elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__)
580580
# define Py_ATOMIC_STD_H
581-
# include "cpython/pyatomic_std.h"
581+
# include "pyatomic_std.h"
582582
# undef Py_ATOMIC_STD_H
583583
#elif defined(_MSC_VER)
584584
# define Py_ATOMIC_MSC_H
585-
# include "cpython/pyatomic_msc.h"
585+
# include "pyatomic_msc.h"
586586
# undef Py_ATOMIC_MSC_H
587587
#else
588588
# error "no available pyatomic implementation for this platform/compiler"

0 commit comments

Comments
 (0)