8000 Catch up with main · python/cpython@eda424d · GitHub
[go: up one dir, main page]

Skip to content

Commit eda424d

Browse files
committed
Catch up with main
2 parents c4bf874 + d4426e8 commit eda424d

File tree

192 files changed

+21565
-31656
lines changed
  • cjkcodecs
  • clinic
  • Objects
  • PC
  • Programs
  • Python
  • Tools
  • Some content is hidden

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

    192 files changed

    +21565
    -31656
    lines changed

    .github/workflows/build.yml

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -518,7 +518,6 @@ jobs:
    518518
    uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
    519519
    with:
    520520
    allowed-failures: >-
    521-
    build_macos,
    522521
    build_macos_free_threaded,
    523522
    build_ubuntu_free_threaded,
    524523
    build_ubuntu_ssltests,

    Doc/bugs.rst

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -38,7 +38,7 @@ though it may take a while to be processed.
    3838
    `Helping with Documentation <https://devguide.python.org/docquality/#helping-with-documentation>`_
    3939
    Comprehensive guide for individuals that are interested in contributing to Python documentation.
    4040

    41-
    `Documentation Translations <https://devguide.python.org/documenting/#translating>`_
    41+
    `Documentation Translations <https://devguide.python.org/documentation/translating/>`_
    4242
    A list of GitHub pages for documentation translation and their primary contacts.
    4343

    4444

    Doc/c-api/bytes.rst

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -155,6 +155,7 @@ called with a non-bytes parameter.
    155155
    156156
    Return the null-terminated contents of the object *obj*
    157157
    through the output variables *buffer* and *length*.
    158+
    Returns ``0`` on success.
    158159
    159160
    If *length* is ``NULL``, the bytes object
    160161
    may not contain embedded null bytes;

    Doc/howto/descriptor.rst

    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -943,6 +943,10 @@ it can be updated:
    943943
    >>> Movie('Star Wars').director
    944944
    'J.J. Abrams'
    945945

    946+
    .. testcleanup::
    947+
    948+
    conn.close()
    949+
    946950

    947951
    Pure Python Equivalents
    948952
    ^^^^^^^^^^^^^^^^^^^^^^^

    Doc/library/difflib.rst

    Lines changed: 5 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -171,9 +171,12 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
    171171
    expressed in the ISO 8601 format. If not specified, the
    172172
    strings default to blanks.
    173173

    174+
    >>> import sys
    175+
    >>> from difflib import *
    174176
    >>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n']
    175177
    >>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n']
    176-
    >>> sys.stdout.writelines(context_diff(s1, s2, fromfile='before.py', tofile='after.py'))
    178+
    >>> sys.stdout.writelines(context_diff(s1, s2, fromfile='before.py',
    179+
    ... tofile='after.py'))
    177180
    *** before.py
    178181
    --- after.py
    179182
    ***************
    @@ -294,13 +297,12 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
    294297
    For inputs that do not have trailing newlines, set the *lineterm* argument to
    295298
    ``""`` so that the output will be uniformly newline free.
    296299

    297-
    The context diff format normally has a header for filenames and modification
    300+
    The unified diff format normally has a header for filenames and modification
    298301
    times. Any or all of these may be specified using strings for *fromfile*,
    299302
    *tofile*, *fromfiledate*, and *tofiledate*. The modification times are normally
    300303
    expressed in the ISO 8601 format. If not specified, the
    301304
    strings default to blanks.
    302305

    303-
    304306
    >>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n']
    305307
    >>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n']
    306308
    >>> sys.stdout.writelines(unified_diff(s1, s2, fromfile='before.py', tofile='after.py'))

    Doc/library/dis.rst

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -824,7 +824,8 @@ iterations of the loop.
    824824
    oparg set to be the exception block depth, for efficient closing of generators.
    825825

    826826
    .. versionchanged:: 3.13
    827-
    this opcode no longer has an oparg
    827+
    oparg is ``1`` if this instruction is part of a yield-from or await, and ``0``
    828+
    otherwise.
    828829

    829830
    .. opcode:: SETUP_ANNOTATIONS
    830831

    Doc/library/ipaddress.rst

    Lines changed: 7 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -219,6 +219,13 @@ write code that handles both IP versions correctly. Address objects are
    219219
    ``True`` if the address is reserved for link-local usage. See
    220220
    :RFC:`3927`.
    221221

    222+
    .. attribute:: ipv6_mapped
    223+
    224+
    :class:`IPv4Address` object representing the IPv4-mapped IPv6 address. See :RFC:`4291`.
    225+
    226+
    .. versionadded:: 3.13
    227+
    228+
    222229
    .. _iana-ipv4-special-registry: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
    223230
    .. _iana-ipv6-special-registry: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
    224231

    Doc/library/logging.handlers.rst

    Lines changed: 1 addition & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -656,9 +656,7 @@ supports sending logging messages to a remote or local Unix syslog.
    656656
    to the other end. This method is called during handler initialization,
    657657
    but it's not regarded as an error if the other end isn't listening at
    658658
    this point - the method will be called again when emitting an event, if
    659-
    but it's not regarded as an error if the other end isn't listening yet
    660-
    --- the method will be called again when emitting an event,
    661-
    if there is no socket at that point.
    659+
    there is no socket at that point.
    662660

    663661
    .. versionadded:: 3.11
    664662

    Doc/library/pdb.rst

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -580,7 +580,7 @@ can be overridden by the local file.
    580580

    581581
    Create an alias called *name* that executes *command*. The *command* must
    582582
    *not* be enclosed in quotes. Replaceable parameters can be indicated by
    583-
    ``%1``, ``%2``, and so on, while ``%*`` is replaced by all the parameters.
    583+
    ``%1``, ``%2``, ... and ``%9``, while ``%*`` is replaced by all the parameters.
    584584
    If *command* is omitted, the current alias for *name* is shown. If no
    585585
    arguments are given, all aliases are listed.
    586586

    Doc/library/typing.rst

    Lines changed: 4 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1954,7 +1954,7 @@ without the dedicated syntax, as documented below.
    19541954

    19551955
    .. doctest::
    19561956

    1957-
    >>> from typing import ParamSpec
    1957+
    >>> from typing import ParamSpec, get_origin
    19581958
    >>> P = ParamSpec("P")
    19591959
    >>> get_origin(P.args) is P
    19601960
    True
    @@ -3059,14 +3059,14 @@ Introspection helpers
    30593059

    30603060
    Return the set of members defined in a :class:`Protocol`.
    30613061

    3062-
    ::
    3062+
    .. doctest::
    30633063

    30643064
    >>> from typing import Protocol, get_protocol_members
    30653065
    >>> class P(Protocol):
    30663066
    ... def a(self) -> str: ...
    30673067
    ... b: int
    3068-
    >>> get_protocol_members(P)
    3069-
    frozenset({'a', 'b'})
    3068+
    >>> get_protocol_members(P) == frozenset({'a', 'b'})
    3069+
    True
    30703070

    30713071
    Raise :exc:`TypeError` for arguments that are not Protocols.
    30723072

    Doc/whatsnew/3.13.rst

    Lines changed: 8 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -185,6 +185,12 @@ and only logged in :ref:`Python Development Mode <devmode>` or on :ref:`Python
    185185
    built on debug mode <debug-build>`.
    186186
    (Contributed by Victor Stinner in :gh:`62948`.)
    187187

    188+
    ipaddress
    189+
    ---------
    190+
    191+
    * Add the :attr:`ipaddress.IPv4Address.ipv6_mapped` property, which returns the IPv4-mapped IPv6 address.
    192+
    (Contributed by Charles Machalow in :gh:`109466`.)
    193+
    188194
    opcode
    189195
    ------
    190196

    @@ -948,7 +954,8 @@ Others
    948954
    CPython bytecode changes
    949955
    ========================
    950956

    951-
    * ``YIELD_VALUE`` no longer has an oparg. The oparg of ``RESUME`` was
    957+
    * The oparg of ``YIELD_VALUE`` is now ``1`` if the yield is part of a
    958+
    yield-from or await, and ``0`` otherwise. The oparg of ``RESUME`` was
    952959
    changed to add a bit indicating whether the except-depth is 1, which
    953960
    is needed to optimize closing of generators.
    954961
    (Contributed by Irit Katriel in :gh:`111354`.)
    @@ -1048,8 +1055,6 @@ New Features
    10481055
    * If Python is built in :ref:`debug mode <debug-build>` or :option:`with
    10491056
    assertions <--with-assertions>`, :c:func:`PyTuple_SET_ITEM` and
    10501057
    :c:func:`PyList_SET_ITEM` now check the index argument with an assertion.
    1051-
    If the assertion fails in :c:func:`PyTuple_SET_ITEM`, make sure that the
    1052-
    tuple size is set before.
    10531058
    (Contributed by Victor Stinner in :gh:`106168`.)
    10541059

    10551060
    * Add :c:func:`PyModule_Add` function: similar to

    Include/cpython/pthread_stubs.h

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -83,6 +83,7 @@ PyAPI_FUNC(int) pthread_create(pthread_t *restrict thread,
    8383
    void *(*start_routine)(void *),
    8484
    void *restrict arg);
    8585
    PyAPI_FUNC(int) pthread_detach(pthread_t thread);
    86+
    PyAPI_FUNC(int) pthread_join(pthread_t thread, void** value_ptr);
    8687
    PyAPI_FUNC(pthread_t) pthread_self(void);
    8788
    PyAPI_FUNC(int) pthread_exit(void *retval) __attribute__ ((__noreturn__));
    8889
    PyAPI_FUNC(int) pthread_attr_init(pthread_attr_t *attr);

    Include/internal/pycore_ceval.h

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -22,6 +22,8 @@ PyAPI_FUNC(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyO
    2222

    2323
    extern int _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
    2424

    25+
    extern int _PyEval_SetOpcodeTrace(PyFrameObject *f, bool enable);
    26+
    2527
    // Helper to look up a builtin object
    2628
    // Export for 'array' shared extension
    2729
    PyAPI_FUNC(PyObject*) _PyEval_GetBuiltin(PyObject *);

    Include/internal/pycore_code.h

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -271,6 +271,8 @@ extern int _PyStaticCode_Init(PyCodeObject *co);
    271271

    272272
    #ifdef Py_STATS
    273273

    274+
    #include "pycore_bitutils.h" // _Py_bit_length
    275+
    274276
    #define STAT_INC(opname, name) do { if (_Py_stats) _Py_stats->opcode_stats[opname].specialization.name++; } while (0)
    275277
    #define STAT_DEC(opname, name) do { if (_Py_stats) _Py_stats->opcode_stats[opname].specialization.name--; } while (0)
    276278
    #define OPCODE_EXE_INC(opname) do { if (_Py_stats) _Py_stats->opcode_stats[opname].execution_count++; } while (0)

    Include/internal/pycore_crossinterp.h

    Lines changed: 11 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -164,6 +164,17 @@ extern void _PyXI_Fini(PyInterpreterState *interp);
    164164
    /* short-term data sharing */
    165165
    /***************************/
    166166

    167+
    // Ultimately we'd like to preserve enough information about the
    168+
    // exception and traceback that we could re-constitute (or at least
    169+
    // simulate, a la traceback.TracebackException), and even chain, a copy
    170+
    // of the exception in the calling interpreter.
    171+
    172+
    typedef struct _excinfo {
    173+
    const char *type;
    174+
    const char *msg;
    175+
    } _Py_excinfo;
    176+
    177+
    167178
    typedef enum error_code {
    168179
    _PyXI_ERR_NO_ERROR = 0,
    169180
    _PyXI_ERR_UNCAUGHT_EXCEPTION = -1,

    Include/internal/pycore_frame.h

    Lines changed: 5 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -36,13 +36,16 @@ extern PyFrameObject* _PyFrame_New_NoTrack(PyCodeObject *code);
    3636
    /* other API */
    3737

    3838
    typedef enum _framestate {
    39-
    FRAME_CREATED = -2,
    40-
    FRAME_SUSPENDED = -1,
    39+
    FRAME_CREATED = -3,
    40+
    FRAME_SUSPENDED = -2,
    41+
    FRAME_SUSPENDED_YIELD_FROM = -1,
    4142
    FRAME_EXECUTING = 0,
    4243
    FRAME_COMPLETED = 1,
    4344
    FRAME_CLEARED = 4
    4445
    } PyFrameState;
    4546

    47+
    #define FRAME_STATE_SUSPENDED(S) ((S) == FRAME_SUSPENDED || (S) == FRAME_SUSPENDED_YIELD_FROM)
    48+
    4649
    enum _frameowner {
    4750
    FRAME_OWNED_BY_THREAD = 0,
    4851
    FRAME_OWNED_BY_GENERATOR = 1,

    Include/internal/pycore_instruments.h

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -63,6 +63,8 @@ typedef uint32_t _PyMonitoringEventSet;
    6363
    PyObject *_PyMonitoring_RegisterCallback(int tool_id, int event_id, PyObject *obj);
    6464

    6565
    int _PyMonitoring_SetEvents(int tool_id, _PyMonitoringEventSet events);
    66+
    int _PyMonitoring_SetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEventSet events);
    67+
    int _PyMonitoring_GetLocalEvents(PyCodeObject *code, int tool_id, _PyMonitoringEventSet *events);
    6668

    6769
    extern int
    6870
    _Py_call_instrumentation(PyThreadState *tstate, int event,

    Include/internal/pycore_interp.h

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -200,7 +200,6 @@ struct _is {
    200200
    uint32_t next_func_version;
    201201

    202202
    _Py_GlobalMonitors monitors;
    203-
    bool f_opcode_trace_set;
    204203
    bool sys_profile_initialized;
    205204
    bool sys_trace_initialized;
    206205
    Py_ssize_t sys_profiling_threads; /* Count of threads with c_profilefunc set */

    Include/internal/pycore_list.h

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -51,8 +51,8 @@ _PyList_AppendTakeRef(PyListObject *self, PyObject *newitem)
    5151
    Py_ssize_t allocated = self->allocated;
    5252
    assert((size_t)len + 1 < PY_SSIZE_T_MAX);
    5353
    if (allocated > len) {
    54-
    Py_SET_SIZE(self, len + 1);
    5554
    PyList_SET_ITEM(self, len, newitem);
    55+
    Py_SET_SIZE(self, len + 1);
    5656
    return 0;
    5757
    }
    5858
    return _PyList_AppendTakeRefListResize(self, newitem);

    Include/internal/pycore_opcode_metadata.h

    Lines changed: 3 additions & 3 deletions
    Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

    Include/internal/pycore_pyerrors.h

    Lines changed: 0 additions & 29 deletions
    Original file line numberDiff line numberDiff line change
    @@ -68,30 +68,6 @@ extern PyStatus _PyErr_InitTypes(PyInterpreterState *);
    6868
    extern void _PyErr_FiniTypes(PyInterpreterState *);
    6969

    7070

    71-
    /* exception snapshots */
    72-
    73-
    // Ultimately we'd like to preserve enough information about the
    74-
    // exception and traceback that we could re-constitute (or at least
    75-
    // simulate, a la traceback.TracebackException), and even chain, a copy
    76-
    // of the exception in the calling interpreter.
    77-
    78-
    typedef struct _excinfo {
    79-
    const char *type;
    80-
    const char *msg;
    81-
    } _Py_excinfo;
    82-
    83-
    extern void _Py_excinfo_Clear(_Py_excinfo *info);
    84-
    extern int _Py_excinfo_Copy(_Py_excinfo *dest, _Py_excinfo *src);
    85-
    extern const char * _Py_excinfo_InitFromException(
    86-
    _Py_excinfo *info,
    87-
    PyObject *exc);
    88-
    extern void _Py_excinfo_Apply(_Py_excinfo *info, PyObject *exctype);
    89-
    extern const char * _Py_excinfo_AsUTF8(
    90-
    _Py_excinfo *info,
    91-
    char *buf,
    92-
    size_t bufsize);
    93-
    94-
    9571
    /* other API */
    9672

    9773
    static inline PyObject* _PyErr_Occurred(PyThreadState *tstate)
    @@ -194,11 +170,6 @@ Py_DEPRECATED(3.12) extern void _PyErr_ChainExceptions(PyObject *, PyObject *, P
    194170
    // Export for '_zoneinfo' shared extension
    195171
    PyAPI_FUNC(void) _PyErr_ChainExceptions1(PyObject *);
    196172

    197-
    // Export for '_lsprof' shared extension
    198-
    PyAPI_FUNC(void) _PyErr_WriteUnraisableMsg(
    199-
    const char *err_msg,
    200-
    PyObject *obj);
    201-
    202173
    #ifdef __cplusplus
    203174
    }
    204175
    #endif

    Include/internal/pycore_pythread.h

    Lines changed: 42 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -106,6 +106,48 @@ PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed_with_retries(
    106106
    PyThread_type_lock,
    107107
    PY_TIMEOUT_T microseconds);
    108108

    109+
    typedef unsigned long long PyThread_ident_t;
    110+
    typedef Py_uintptr_t PyThread_handle_t;
    111+
    112+
    #define PY_FORMAT_THREAD_IDENT_T "llu"
    113+
    #define Py_PARSE_THREAD_IDENT_T "K"
    114+
    115+
    PyAPI_FUNC(PyThread_ident_t) PyThread_get_thread_ident_ex(void);
    116+
    117+
    /* Thread joining APIs.
    118+
    *
    119+
    * These APIs have a strict contract:
    120+
    * - Either PyThread_join_thread or PyThread_detach_thread must be called
    121+
    * exactly once with the given handle.
    122+
    * - Calling neither PyThread_join_thread nor PyThread_detach_thread results
    123+
    * in a resource leak until the end of the process.
    124+
    * - Any other usage, such as calling both PyThread_join_thread and
    125+
    * PyThread_detach_thread, or calling them more than once (including
    126+
    * simultaneously), results in undefined behavior.
    127+
    */
    128+
    PyAPI_FUNC(int) PyThread_start_joinable_thread(void (*func)(void *),
    129+
    void *arg,
    130+
    PyThread_ident_t* ident,
    131+
    PyThread_handle_t* handle);
    132+
    /*
    133+
    * Join a thread started with `PyThread_start_joinable_thread`.
    134+
    * This function cannot be interrupted. It returns 0 on success,
    135+
    * a non-zero value on failure.
    136+
    */
    137+
    PyAPI_FUNC(int) PyThread_join_thread(PyThread_handle_t);
    138+
    /*
    139+
    * Detach a thread started with `PyThread_start_joinable_thread`, such
    140+
    * that its resources are relased as soon as it exits.
    141+
    * This function cannot be interrupted. It returns 0 on success,
    142+
    * a non-zero value on failure.
    143+
    */
    144+
    PyAPI_FUNC(int) PyThread_detach_thread(PyThread_handle_t);
    145+
    146+
    /*
    147+
    * Obtain the new thread ident and handle in a forked child process.
    148+
    */
    149+
    PyAPI_FUNC(void) PyThread_update_thread_after_fork(PyThread_ident_t* ident,
    150+
    PyThread_handle_t* handle);
    109151

    110152
    #ifdef __cplusplus
    111153
    }

    Include/moduleobject.h

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -73,7 +73,9 @@ struct PyModuleDef_Slot {
    7373

    7474
    #define Py_mod_create 1
    7575
    #define Py_mod_exec 2
    76-
    #define Py_mod_multiple_interpreters 3
    76+
    #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
    77+
    # define Py_mod_multiple_interpreters 3
    78+
    #endif
    7779

    7880
    #ifndef Py_LIMITED_API
    7981
    #define _Py_mod_LAST_SLOT 3

    0 commit comments

    Comments
     (0)
    0