8000 Merge branch 'main' into meth_o-for-htons · python/cpython@39e68a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 39e68a8

Browse files
authored
Merge branch 'main' into meth_o-for-htons
2 parents e55aac5 + d4426e8 commit 39e68a8

File tree

77 files changed

+20018
-30969
lines changed
  • test_capi
  • test_concurrent_futures
  • test_tools
  • test_zipfile
  • Misc/NEWS.d/next
  • Modules
  • Objects
  • Python
  • Tools/unicode
  • Some content is hidden

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

    77 files changed

    +20018
    -30969
    lines changed

    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/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/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/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/whatsnew/3.13.rst

    Lines changed: 6 additions & 0 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

    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_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_pyerrors.h

    Lines changed: 0 additions & 24 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)

    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

    Lib/bdb.py

    Lines changed: 7 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -32,6 +32,7 @@ def __init__(self, skip=None):
    3232
    self.skip = set(skip) if skip else None
    3333
    self.breaks = {}
    3434
    self.fncache = {}
    35+
    self.frame_trace_lines = {}
    3536
    self.frame_returning = None
    3637

    3738
    self._load_breaks()
    @@ -331,6 +332,9 @@ def set_trace(self, frame=None):
    331332
    while frame:
    332333
    frame.f_trace = self.trace_dispatch
    333334
    self.botframe = frame
    335+
    # We need f_trace_liens == True for the debugger to work
    336+
    self.frame_trace_lines[frame] = frame.f_trace_lines
    337+
    frame.f_trace_lines = True
    334338
    frame = frame.f_back
    335339
    self.set_step()
    336340
    sys.settrace(self.trace_dispatch)
    @@ -349,6 +353,9 @@ def set_continue(self):
    349353
    while frame and frame is not self.botframe:
    350354
    del frame.f_trace
    351355
    frame = frame.f_back
    356+
    for frame, prev_trace_lines in self.frame_trace_lines.items():
    357+
    frame.f_trace_lines = prev_trace_lines
    358+
    self.frame_trace_lines = {}
    352359

    353360
    def set_quit(self):
    354361
    """Set quitting attribute to True.

    Lib/doctest.py

    Lines changed: 5 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1399,10 +1399,14 @@ def __run(self, test, compileflags, out):
    13991399
    # we don't care about the carets / suggestions / etc
    14001400
    # We only care about the error message and notes.
    14011401
    # They start with `SyntaxError:` (or any other class name)
    1402+
    exception_line_prefixes = (
    1403+
    f"{exception[0].__qualname__}:",
    1404+
    f"{exception[0].__module__}.{exception[0].__qualname__}:",
    1405+
    )
    14021406
    exc_msg_index = next(
    14031407
    index
    14041408
    for index, line in enumerate(formatted_ex)
    1405-
    if line.startswith(f"{exception[0].__name__}:")
    1409+
    if line.startswith(exception_line_prefixes)
    14061410
    )
    14071411
    formatted_ex = formatted_ex[exc_msg_index:]
    14081412

    Lib/ipaddress.py

    Lines changed: 10 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1389,6 +1389,16 @@ def is_link_local(self):
    13891389
    """
    13901390
    return self in self._constants._linklocal_network
    13911391

    1392+
    @property
    1393+
    def ipv6_mapped(self):
    1394+
    """Return the IPv4-mapped IPv6 address.
    1395+
    1396+
    Returns:
    1397+
    The IPv4-mapped IPv6 address per RFC 4291.
    1398+
    1399+
    """
    1400+
    return IPv6Address(f'::ffff:{self}')
    1401+
    13921402

    13931403
    class IPv4Interface(IPv4Address):
    13941404

    Lib/pdb.py

    Lines changed: 27 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -597,11 +597,20 @@ def precmd(self, line):
    597597
    args = line.split()
    598598
    while args[0] in self.aliases:
    599599
    line = self.aliases[args[0]]
    600-
    ii = 1
    601-
    for tmpArg in args[1:]:
    602-
    line = line.replace("%" + str(ii),
    603-
    tmpArg)
    604-
    ii += 1
    600+
    for idx in range(1, 10):
    601+
    if f'%{idx}' in line:
    602+
    if idx >= len(args):
    603+
    self.error(f"Not enough arguments for alias '{args[0]}'")
    604+
    # This is a no-op
    605+
    return "!"
    606+
    line = line.replace(f'%{idx}', args[idx])
    607+
    elif '%*' not in line:
    608+
    if idx < len(args):
    609+
    self.error(f"Too many arguments for alias '{args[0]}'")
    610+
    # This is a no-op
    611+
    return "!"
    612+
    break
    613+
    605614
    line = line.replace("%*", ' '.join(args[1:]))
    606615
    args = line.split()
    607616
    # split into ';;' separated commands
    @@ -616,6 +625,7 @@ def precmd(self, line):
    616625

    617626
    # Replace all the convenience variables
    618627
    line = re.sub(r'\$([a-zA-Z_][a-zA-Z0-9_]*)', r'__pdb_convenience_variables["\1"]', line)
    628+
    619629
    return line
    620630

    621631
    def onecmd(self, line):
    @@ -1797,7 +1807,18 @@ def do_alias(self, arg):
    17971807
    else:
    17981808
    self.error(f"Unknown alias '{args[0]}'")
    17991809
    else:
    1800-
    self.aliases[args[0]] = ' '.join(args[1:])
    1810+
    # Do a validation check to make sure no replaceable parameters
    1811+
    # are skipped if %* is not used.
    1812+
    alias = ' '.join(args[1:])
    1813+
    if '%*' not in alias:
    1814+
    consecutive = True
    1815+
    for idx in range(1, 10):
    1816+
    if f'%{idx}' not in alias:
    1817+
    consecutive = False
    1818+
    if f'%{idx}' in alias and not consecutive:
    1819+
    self.error("Replaceable parameters must be consecutive")
    1820+
    return
    1821+
    self.aliases[args[0]] = alias
    18011822

    18021823
    def do_unalias(self, arg):
    18031824
    """unalias name

    Lib/test/_test_multiprocessing.py

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2693,6 +2693,9 @@ def test_make_pool(self):
    26932693
    p.join()
    26942694

    26952695
    def test_terminate(self):
    2696+
    if self.TYPE == 'threads':
    2697+
    self.skipTest("Threads cannot be terminated")
    2698+
    26962699
    # Simulate slow tasks which take "forever" to complete
    26972700
    p = self.Pool(3)
    26982701
    args = [support.LONG_TIMEOUT for i in range(10_000)]

    Lib/test/ziptestdata/README.md renamed to Lib/test/archivetestdata/README.md

    Lines changed: 8 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,29 +1,31 @@
    1-
    # Test data for `test_zipfile`
    1+
    # Test data for `test_zipfile`, `test_tarfile` (and even some others)
    22

    3-
    The test executables in this directory are created manually from header.sh and
    3+
    ## `test_zipfile`
    4+
    5+
    The test executables in this directory are created manually from `header.sh` and
    46
    the `testdata_module_inside_zip.py` file. You must have Info-ZIP's zip utility
    57
    installed (`apt install zip` on Debian).
    68

    7-
    ## Purpose
    9+
    ### Purpose of `exe_w 10000 ith_zip` and `exe_with_z64`
    810

    911
    These are used to test executable files with an appended zipfile, in a scenario
    1012
    where the executable is _not_ a Python interpreter itself so our automatic
    1113
    zipimport machinery (that'd look for `__main__.py`) is not being used.
    1214

    13-
    ## Updating the test executables
    15+
    ### Updating the test executables
    1416

    1517
    If you update header.sh or the testdata_module_inside_zip.py file, rerun the
    1618
    commands below. These are expected to be rarely changed, if ever.
    1719

    18-
    ### Standard old format (2.0) zip file
    20+
    #### Standard old format (2.0) zip file
    1921

    2022
    ```
    2123
    zip -0 zip2.zip testdata_module_inside_zip.py
    2224
    cat header.sh zip2.zip >exe_with_zip
    2325
    rm zip2.zip
    2426
    ```
    2527

    26-
    ### Modern format (4.5) zip64 file
    28+
    #### Modern format (4.5) zip64 file
    2729

    2830
    Redirecting from stdin forces Info-ZIP's zip tool to create a zip64.
    2931

    @@ -32,4 +34,3 @@ zip -0 <testdata_module_inside_zip.py >zip64.zip
    3234
    cat header.sh zip64.zip >exe_with_z64
    3335
    rm zip64.zip
    3436
    ```
    35-
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.

    Lib/test/audit-tests.py

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -455,6 +455,9 @@ def __call__(self):
    455455
    i = _thread.start_new_thread(test_func(), ())
    456456
    lock.acquire()
    457457

    458+
    handle = _thread.start_joinable_thread(test_func())
    459+
    handle.join()
    460+
    458461

    459462
    def test_threading_abort():
    460463
    # Ensures that aborting PyThreadState_New raises the correct exception

    Lib/test/test_audit.py

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -209,6 +209,8 @@ def test_threading(self):
    209209
    expected = [
    210210
    ("_thread.start_new_thread", "(<test_func>, (), None)"),
    211211
    ("test.test_func", "()"),
    212+
    ("_thread.start_joinable_thread", "(<test_func>,)"),
    213+
    ("test.test_func", "()"),
    212214
    ]
    213215

    214216
    self.assertEqual(actual, expected)

    0 commit comments

    Comments
     (0)
    0