8000 Merge branch 'main' into small_int_immortal_v2 · python/cpython@2f73d47 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f73d47

Browse files
authored
Merge branch 'main' into small_int_immortal_v2
2 parents d9c26d3 + 23f2e8f commit 2f73d47
  • test_json
  • test_pathlib
  • test_unittest
  • unittest
  • Misc/NEWS.d/next
  • Modules
  • Tools
  • iOS/Resources/bin
  • Some content is hidden

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

    69 files changed

    +847
    -667
    lines changed

    .github/workflows/build.yml

    Lines changed: 9 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -235,10 +235,19 @@ jobs:
    235235
    free-threading:
    236236
    - false
    237237
    - true
    238+
    os:
    239+
    - ubuntu-24.04
    240+
    - ubuntu-24.04-aarch64
    241+
    is-fork: # only used for the exclusion trick
    242+
    - ${{ github.repository_owner != 'python' }}
    243+
    exclude:
    244+
    - os: ubuntu-24.04-aarch64
    245+
    is-fork: true
    238246
    uses: ./.github/workflows/reusable-ubuntu.yml
    239247
    with:
    240248
    config_hash: ${{ needs.check_source.outputs.config_hash }}
    241249
    free-threading: ${{ matrix.free-threading }}
    250+
    os: ${{ matrix.os }}
    242251

    243252
    build_ubuntu_ssltests:
    244253
    name: 'Ubuntu SSL tests with OpenSSL'

    .github/workflows/jit.yml

    Lines changed: 7 additions & 24 deletions
    Original file line numberDiff line numberDiff line change
    @@ -28,7 +28,7 @@ concurrency:
    2828
    jobs:
    2929
    interpreter:
    3030
    name: Interpreter (Debug)
    31-
    runs-on: ubuntu-22.04
    31+
    runs-on: ubuntu-24.04
    3232
    timeout-minutes: 90
    3333
    steps:
    3434
    - uses: actions/checkout@v4
    @@ -78,10 +78,11 @@ jobs:
    7878
    runner: macos-14
    7979
    - target: x86_64-unknown-linux-gnu/gcc
    8080
    architecture: x86_64
    81-
    runner: ubuntu-22.04
    81+
    runner: ubuntu-24.04
    8282
    - target: aarch64-unknown-linux-gnu/gcc
    8383
    architecture: aarch64
    84-
    runner: ubuntu-22.04
    84+
    # Forks don't have access to our paid AArch64 runners. These jobs are skipped below:
    85+
    runner: ${{ github.repository_owner == 'python' && 'ubuntu-24.04-aarch64' || 'ubuntu-24.04' }}
    8586
    steps:
    8687
    - uses: actions/checkout@v4
    8788
    - uses: actions/setup-python@v5
    @@ -118,37 +119,19 @@ jobs:
    118119
    ./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
    119120
    120121
    - name: Native Linux
    121-
    if: runner.os == 'Linux' && matrix.architecture == 'x86_64'
    122+
    # Forks don't have access to our paid AArch64 runners. Skip those:
    123+
    if: runner.os == 'Linux' && (matrix.architecture == 'x86_64' || github.repository_owner == 'python')
    122124
    run: |
    123125
    sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
    124126
    export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
    125127
    ./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }}
    126128
    make all --jobs 4
    127129
    ./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
    128130
    129-
    - name: Emulated Linux
    130-
    if: runner.os == 'Linux' && matrix.architecture != 'x86_64'
    131-
    # The --ignorefile on ./python -m test is used to exclude tests known to fail when running on an emulated Linux.
    132-
    run: |
    133-
    sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
    134-
    export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
    135-
    ./configure --prefix="$(pwd)/../build"
    136-
    make install --jobs 4
    137-
    make clean --jobs 4
    138-
    export HOST=${{ matrix.architecture }}-linux-gnu
    139-
    sudo apt install --yes "gcc-$HOST" qemu-user
    140-
    export QEMU_LD_PREFIX="/usr/$HOST"
    141-
    CC="$HOST-gcc" \
    142-
    CPP="$HOST-gcc --preprocess" \
    143-
    HOSTRUNNER=qemu-${{ matrix.architecture }} \
    144-
    ./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }} --build=x86_64-linux-gnu --host="$HOST" --with-build-python=../build/bin/python3 --with-pkg-config=no ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=yes
    145-
    make all --jobs 4
    146-
    ./python -m test --ignorefile=Tools/jit/ignore-tests-emulated-linux.txt --multiprocess 0 --timeout 4500 --verbose2 --verbose3
    147-
    148131
    jit-with-disabled-gil:
    149132
    name: Free-Threaded (Debug)
    150133
    needs: interpreter
    151-
    runs-on: ubuntu-22.04
    134+
    runs-on: ubuntu-24.04
    152135
    strategy:
    153136
    matrix:
    154137
    llvm:

    .github/workflows/reusable-ubuntu.yml

    Lines changed: 8 additions & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -11,16 +11,16 @@ on:
    1111
    required: false
    1212
    type: boolean
    1313
    default: false
    14+
    os:
    15+
    description: OS to run the job
    16+
    required: true
    17+
    type: string
    1418

    1519
    jobs:
    1620
    build_ubuntu_reusable:
    17-
    name: 'build and test'
    21+
    name: build and test (${{ inputs.os }})
    1822
    timeout-minutes: 60
    19-
    runs-on: ${{ matrix.os }}
    20-
    strategy:
    21-
    fail-fast: false
    22-
    matrix:
    23-
    os: [ubuntu-24.04, ubuntu-24.04-aarch64]
    23+
    runs-on: ${{ inputs.os }}
    2424
    env:
    2525
    FORCE_COLOR: 1
    2626
    OPENSSL_VER: 3.0.15
    @@ -42,7 +42,7 @@ jobs:
    4242
    uses: actions/cache@v4
    4343
    with:
    4444
    path: ./multissl/openssl/${{ env.OPENSSL_VER }}
    45-
    key: ${{ matrix.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
    45+
    key: ${{ inputs.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
    4646
    - name: Install OpenSSL
    4747
    if: steps.cache-openssl.outputs.cache-hit != 'true'
    4848
    run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux
    @@ -84,7 +84,7 @@ jobs:
    8484
    working-directory: ${{ env.CPYTHON_BUILDDIR }}
    8585
    run: make -j
    8686
    - name: Build CPython out-of-tree (for compiler warning check)
    87-
    if: ${{ !inputs.free-threading}}
    87+
    if: ${{ !inputs.free-threading }}
    8888
    working-directory: ${{ env.CPYTHON_BUILDDIR }}
    8989
    run: set -o pipefail; make -j --output-sync 2>&1 | tee compiler_output_ubuntu.txt
    9090
    - name: Display build info

    Doc/c-api/unicode.rst

    Lines changed: 9 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1588,6 +1588,11 @@ object.
    15881588
    15891589
    Create a Unicode writer instance.
    15901590
    1591+
    *length* must be greater than or equal to ``0``.
    1592+
    1593+
    If *length* is greater than ``0``, preallocate an internal buffer of
    1594+
    *length* characters.
    1595+
    15911596
    Set an exception and return ``NULL`` on error.
    15921597
    15931598
    .. c:function:: PyObject* PyUnicodeWriter_Finish(PyUnicodeWriter *writer)
    @@ -1596,12 +1601,16 @@ object.
    15961601
    15971602
    Set an exception and return ``NULL`` on error.
    15981603
    1604+
    The writer instance is invalid after this call.
    1605+
    15991606
    .. c:function:: void PyUnicodeWriter_Discard(PyUnicodeWriter *writer)
    16001607
    16011608
    Discard the internal Unicode buffer and destroy the writer instance.
    16021609
    16031610
    If *writer* is ``NULL``, no operation is performed.
    16041611
    1612+
    The writer instance is invalid after this call.
    1613+
    16051614
    .. c:function:: int PyUnicodeWriter_WriteChar(PyUnicodeWriter *writer, Py_UCS4 ch)
    16061615
    16071616
    Write the single Unicode character *ch* into *writer*.

    Doc/conf.py

    Lines changed: 7 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -78,6 +78,13 @@
    7878
    .. |python_version_literal| replace:: ``Python {version}``
    7979
    .. |python_x_dot_y_literal| replace:: ``python{version}``
    8080
    .. |usr_local_bin_python_x_dot_y_literal| replace:: ``/usr/local/bin/python{version}``
    81+
    82+
    .. Apparently this how you hack together a formatted link:
    83+
    (https://www.docutils.org/docs/ref/rst/directives.html#replacement-text)
    84+
    .. |FORCE_COLOR| replace:: ``FORCE_COLOR``
    85+
    .. _FORCE_COLOR: https://force-color.org/
    86+
    .. |NO_COLOR| replace:: ``NO_COLOR``
    87+
    .. _NO_COLOR: https://no-color.org/
    8188
    """
    8289

    8390
    # There are two options for replacing |today|. Either, you set today to some

    Doc/library/dis.rst

    Lines changed: 7 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -60,6 +60,8 @@ interpreter.
    6060
    The :option:`-P <dis --show-positions>` command-line option
    6161
    and the ``show_positions`` argument were added.
    6262

    63+
    The :option:`-S <dis --specialized>` command-line option is added.
    64+
    6365
    Example: Given the function :func:`!myfunc`::
    6466

    6567
    def myfunc(alist):
    @@ -89,7 +91,7 @@ The :mod:`dis` module can be invoked as a script from the command line:
    8991

    9092
    .. code-block:: sh
    9193
    92-
    python -m dis [-h] [-C] [-O] [-P] [infile]
    94+
    python -m dis [-h] [-C] [-O] [-P] [-S] [infile]
    9395
    9496
    The following options are accepted:
    9597

    @@ -111,6 +113,10 @@ The following options are accepted:
    111113

    112114
    Show positions of instructions in the source code.
    113115

    116+
    .. cmdoption:: -S, --specialized
    117+
    118+
    Show specialized bytecode.
    119+
    114120
    If :file:`infile` is specified, its disassembled code will be written to stdout.
    115121
    Otherwise, disassembly is performed on compiled source code received from stdin.
    116122

    Doc/library/doctest.rst

    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -136,6 +136,10 @@ examples of doctests in the standard Python test suite and libraries.
    136136
    Especially useful examples can be found in the standard test file
    137137
    :file:`Lib/test/test_doctest/test_doctest.py`.
    138138

    139+
    .. versionadded:: 3.13
    140+
    Output is colorized by default and can be
    141+
    :ref:`controlled using environment variables <using-on-controlling-color>`.
    142+
    139143

    140144
    .. _doctest-simple-testmod:
    141145

    Doc/library/traceback.rst

    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -44,6 +44,10 @@ The module's API can be divided into two parts:
    4444
    necessary for later formatting without holding references to actual exception
    4545
    and traceback objects.
    4646

    47+
    .. versionadded:: 3.13
    48+
    Output is colorized by default and can be
    49+
    :ref:`controlled using environment variables <using-on-controlling-color>`.
    50+
    4751

    4852
    Module-Level Functions
    4953
    ----------------------

    Doc/library/unittest.rst

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -46,7 +46,6 @@ test runner
    4646
    a textual interface, or return a special value to indicate the results of
    4747
    executing the tests.
    4848

    49-
    5049
    .. seealso::
    5150

    5251
    Module :mod:`doctest`
    @@ -198,6 +197,9 @@ For a list of all the command-line options::
    198197
    In earlier versions it was only possible to run individual test methods and
    199198
    not modules or classes.
    200199

    200+
    .. versionadded:: 3.14
    201+
    Output is colorized by default and can be
    202+
    :ref:`controlled using environment variables <using-on-controlling-color>`.
    201203

    202204
    Command-line options
    203205
    ~~~~~~~~~~~~~~~~~~~~

    Doc/using/cmdline.rst

    Lines changed: 0 additions & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -663,14 +663,6 @@ output. To control the color output only in the Python interpreter, the
    663663
    precedence over ``NO_COLOR``, which in turn takes precedence over
    664664
    ``FORCE_COLOR``.
    665665

    666-
    .. Apparently this how you hack together a formatted link:
    667-
    668-
    .. |FORCE_COLOR| replace:: ``FORCE_COLOR``
    669-
    .. _FORCE_COLOR: https://force-color.org/
    670-
    671-
    .. |NO_COLOR| replace:: ``NO_COLOR``
    672-
    .. _NO_COLOR: https://no-color.org/
    673-
    674666
    Options you shouldn't use
    675667
    ~~~~~~~~~~~~~~~~~~~~~~~~~
    676668

    Doc/whatsnew/3.13.rst

    Lines changed: 0 additions & 9 deletions
    Original file line numberDiff line numberDiff line change
    @@ -252,15 +252,6 @@ Improved error messages
    252252
    the canonical |NO_COLOR|_ and |FORCE_COLOR|_ environment variables.
    253253
    (Contributed by Pablo Galindo Salgado in :gh:`112730`.)
    254254

    255-
    .. Apparently this how you hack together a formatted link:
    256-
    (https://www.docutils.org/docs/ref/rst/directives.html#replacement-text)
    257-
    258-
    .. |FORCE_COLOR| replace:: ``FORCE_COLOR``
    259-
    .. _FORCE_COLOR: https://force-color.org/
    260-
    261-
    .. |NO_COLOR| replace:: ``NO_COLOR``
    262-
    .. _NO_COLOR: https://no-color.org/
    263-
    264255
    * A common mistake is to write a script with the same name as a
    265256
    standard library module. When this results in errors, we now
    266257
    display a more helpful error message:

    Doc/whatsnew/3.14.rst

    Lines changed: 13 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -348,12 +348,18 @@ dis
    348348
    This feature is also exposed via :option:`dis --show-positions`.
    349349
    (Contributed by Bénédikt Tran in :gh:`123165`.)
    350350

    351+
    * Add the :option:`dis --specialized` command-line option to
    352+
    show specialized bytecode.
    353+
    (Contributed by Bénédikt Tran in :gh:`127413`.)
    354+
    355+
    351356
    errno
    352357
    -----
    353358

    354359
    * Add :data:`errno.EHWPOISON` error code.
    355360
    (Contributed by James Roy in :gh:`126585`.)
    356361

    362+
    357363
    fractions
    358364
    ---------
    359365

    @@ -610,6 +616,13 @@ unicodedata
    610616
    unittest
    611617
    --------
    612618

    619+
    * :mod:`unittest` output is now colored by default.
    620+
    This can be controlled via the :envvar:`PYTHON_COLORS` environment
    621+
    variable as well as the canonical |NO_COLOR|_
    622+
    and |FORCE_COLOR|_ environment variables.
    623+
    See also :ref:`using-on-controlling-color`.
    624+
    (Contributed by Hugo van Kemenade in :gh:`127221`.)
    625+
    613626
    * unittest discovery supports :term:`namespace package` as start
    614627
    directory again. It was removed in Python 3.11.
    615628
    (Contributed by Jacob Walls in :gh:`80958`.)

    Include/internal/pycore_backoff.h

    Lines changed: 3 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -115,10 +115,9 @@ initial_jump_backoff_counter(void)
    115115
    /* Initial exit temperature.
    116116
    * Must be larger than ADAPTIVE_COOLDOWN_VALUE,
    117117
    * otherwise when a side exit warms up we may construct
    118-
    * a new trace before the Tier 1 code has properly re-specialized.
    119-
    * Backoff sequence 64, 128, 256, 512, 1024, 2048, 4096. */
    120-
    #define SIDE_EXIT_INITIAL_VALUE 63
    121-
    #define SIDE_EXIT_INITIAL_BACKOFF 6
    118+
    * a new trace before the Tier 1 code has properly re-specialized. */
    119+
    #define SIDE_EXIT_INITIAL_VALUE 4095
    120+
    #define SIDE_EXIT_INITIAL_BACKOFF 12
    122121

    123122
    static inline _Py_BackoffCounter
    124123
    initial_temperature_backoff_counter(void)

    Lib/dis.py

    Lines changed: 4 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1125,6 +1125,8 @@ def main():
    11251125
    help='show instruction offsets')
    11261126
    parser.add_argument('-P', '--show-positions', action='store_true',
    11271127
    help='show instruction positions')
    1128+
    parser.add_argument('-S', '--specialized', action='store_true',
    1129+
    help='show specialized bytecode')
    11281130
    parser.add_argument('infile', nargs='?', default='-')
    11291131
    args = parser.parse_args()
    11301132
    if args.infile == '-':
    @@ -1135,7 +1137,8 @@ def main():
    11351137
    with open(args.infile, 'rb') as infile:
    11361138
    source = infile.read()
    11371139
    code = compile(source, name, "exec")
    1138-
    dis(code, show_caches=args.show_caches, show_offsets=args.show_offsets, show_positions=args.show_positions)
    1140+
    dis(code, show_caches=args.show_caches, adaptive=args.specialized,
    1141+
    show_offsets=args.show_offsets, show_positions=args.show_positions)
    11391142

    11401143
    if __name__ == "__main__":
    11411144
    main()

    Lib/test/list_tests.py

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -6,7 +6,7 @@
    66
    from functools import cmp_to_key
    77

    88
    from test import seq_tests
    9-
    from test.support import ALWAYS_EQ, NEVER_EQ, get_c_recursion_limit
    9+
    from test.support import ALWAYS_EQ, NEVER_EQ, get_c_recursion_limit, skip_emscripten_stack_overflow
    1010

    1111

    1212
    class CommonTest(seq_tests.CommonTest):
    @@ -59,6 +59,7 @@ def test_repr(self):
    5959
    self.assertEqual(str(a2), "[0, 1, 2, [...], 3]")
    6060
    self.assertEqual(repr(a2), "[0, 1, 2, [...], 3]")
    6161

    62+
    @skip_emscripten_stack_overflow()
    6263
    def test_repr_deep(self):
    6364
    a = self.type2test([])
    6465
    for i in range(get_c_recursion_limit() + 1):

    Lib/test/mapping_tests.py

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1,7 +1,7 @@
    11
    # tests common to dict and UserDict
    22
    import unittest
    33
    import collections
    4-
    from test.support import get_c_recursion_limit
    4+
    from test.support import get_c_recursion_limit, skip_emscripten_stack_overflow
    55

    66

    77
    class BasicTestMappingProtocol(unittest.TestCase):
    @@ -622,6 +622,7 @@ def __repr__(self):
    622622
    d = self._full_mapping({1: BadRepr()})
    623623
    self.assertRaises(Exc, repr, d)
    624624

    625+
    @skip_emscripten_stack_overflow()
    625626
    def test_repr_deep(self):
    626627
    d = self._empty_mapping()
    627628
    for i in range(get_c_recursion_limit() + 1):

    Lib/test/support/__init__.py

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -535,6 +535,9 @@ def skip_android_selinux(name):
    535535
    is_emscripten = sys.platform == "emscripten"
    536536
    is_wasi = sys.platform == "wasi"
    537537

    538+
    def skip_emscripten_stack_overflow():
    539+
    return unittest.skipIf(is_emscripten, "Exhausts limited stack on Emscripten")
    540+
    538541
    is_apple_mobile = sys.platform in {"ios", "tvos", "watchos"}
    539542
    is_apple = is_apple_mobile or sys.platform == "darwin"
    540543

    Lib/test/test__locale.py

    Lines changed: 5 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -102,6 +102,11 @@ def accept(loc):
    102102
    # ps_AF doesn't work on Windows: see bpo-38324 (msg361830)
    103103
    del known_numerics['ps_AF']
    104104

    105+
    if sys.platform == 'sunos5':
    106+
    # On Solaris, Japanese ERAs start with the year 1927,
    107+
    # and thus there's less of them.
    108+
    known_era['ja_JP'] = (5, '+:1:2019/05/01:2019/12/31:令和:%EC元年')
    109+
    105110
    class _LocaleTests(unittest.TestCase):
    106111

    107112
    def setUp(self):

    0 commit comments

    Comments
     (0)
    0