8000 Merge branch 'main' of github.com:python/cpython · python/cpython@aae9a5f · GitHub
[go: up one dir, main page]

Skip to content

Commit aae9a5f

Browse files
committed
Merge branch 'main' of github.com:python/cpython
2 parents a89f02e + 036bbb1 commit aae9a5f

File tree

226 files changed

+3346
-1340
lines changed
  • Tests
  • Windows
  • macOS
  • Modules
  • Objects
  • PC
  • PCbuild
  • Python
  • Tools
  • Some content is hidden

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

    226 files changed

    +3346
    -1340
    lines changed

    .github/workflows/doc.yml

    Lines changed: 9 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -38,8 +38,15 @@ jobs:
    3838
    run: make -j4
    3939
    - name: 'Install build dependencies'
    4040
    run: make -C Doc/ PYTHON=../python venv
    41-
    - name: 'Build documentation'
    42-
    run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" doctest html
    41+
    # Run "check doctest html" as 3 steps to get a more readable output
    42+
    # in the web UI
    43+
    - name: 'Check documentation'
    44+
    run: make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" check
    45+
    # Use "xvfb-run" since some doctest tests open GUI windows
    46+
    - name: 'Run documentation doctest'
    47+
    run: xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" doctest
    48+
    - name: 'Build HTML documentation'
    49+
    run: make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W --keep-going -j4" html
    4350
    - name: 'Upload'
    4451
    uses: actions/upload-artifact@v2.2.4
    4552
    with:

    Doc/c-api/apiabiversion.rst

    Lines changed: 9 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -58,5 +58,14 @@ See :ref:`stable` for a discussion of API and ABI stability across versions.
    5858
    Thus ``3.4.1a2`` is hexversion ``0x030401a2`` and ``3.10.0`` is
    5959
    hexversion ``0x030a00f0``.
    6060

    61+
    This version is also available via the symbol :data:`Py_Version`.
    62+
    63+
    .. c:var:: const unsigned long Py_Version
    64+
    65+
    The Python runtime version number encoded in a single constant integer, with
    66+
    the same format as the c:macro:`PY_VERSION_HEX` macro.
    67+
    This contains the Python version used at run time.
    68+
    69+
    .. versionadded:: 3.11
    6170

    6271
    All the given macros are defined in :source:`Include/patchlevel.h`.

    Doc/c-api/init.rst

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -553,6 +553,8 @@ Process-wide parameters
    553553
    period. The returned string points into static storage; the caller should not
    554554
    modify its value. The value is available to Python code as :data:`sys.version`.
    555555
    556+
    See also the :data:`Py_Version` constant.
    557+
    556558
    557559
    .. c:function:: const char* Py_GetPlatform()
    558560

    Doc/data/stable_abi.dat

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -830,6 +830,7 @@ type,Py_UCS4,3.2,
    830830
    macro,Py_UNBLOCK_THREADS,3.2,
    831831
    var,Py_UTF8Mode,3.8,
    832832
    function,Py_VaBuildValue,3.2,
    833+
    var,Py_Version,3.11,
    833834
    function,Py_XNewRef,3.10,
    834835
    type,Py_intptr_t,3.2,
    835836
    type,Py_ssize_t,3.2,

    Doc/library/dis.rst

    Lines changed: 5 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -584,12 +584,14 @@ iterations of the loop.
    584584

    585585
    .. opcode:: WITH_EXCEPT_START
    586586

    587-
    Calls the function in position 7 on the stack with the top three
    587+
    Calls the function in position 8 on the stack with the top three
    588588
    items on the stack as arguments.
    589589
    Used to implement the call ``context_manager.__exit__(*exc_info())`` when an exception
    590590
    has occurred in a :keyword:`with` statement.
    591591

    592592
    .. versionadded:: 3.9
    593+
    .. versionchanged:: 3.11
    594+
    The ``__exit__`` function is in position 8 of the stack rather than 7.
    593595

    594596

    595597
    .. opcode:: POP_EXCEPT_AND_RERAISE
    @@ -1168,9 +1170,8 @@ All of the following opcodes use their arguments.
    11681170

    11691171
    .. opcode:: GEN_START (kind)
    11701172

    1171-
    Pops TOS. If TOS was not ``None``, raises an exception. The ``kind``
    1172-
    operand corresponds to the type of generator or coroutine and determines
    1173-
    the error message. The legal kinds are 0 for generator, 1 for coroutine,
    1173+
    Pops TOS. The ``kind`` operand corresponds to the type of generator or
    1174+
    coroutine. The legal kinds are 0 for generator, 1 for coroutine,
    11741175
    and 2 for async generator.
    11751176

    11761177
    .. versionadded:: 3.10

    Doc/library/fcntl.rst

    Lines changed: 5 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -44,6 +44,11 @@ descriptor.
    4444
    ``F_SETPIPE_SZ`` constants, which allow to check and modify a pipe's size
    4545
    respectively.
    4646

    47+
    .. versionchanged:: 3.11
    48+
    On FreeBSD, the fcntl module exposes the ``F_DUP2FD`` and ``F_DUP2FD_CLOEXEC``
    49+
    constants, which allow to duplicate a file descriptor, the latter setting
    50+
    ``FD_CLOEXEC`` flag in addition.
    51+
    4752
    The module defines the following functions:
    4853

    4954

    Doc/library/stdtypes.rst

    Lines changed: 10 additions & 9 deletions
    Original file line numberDiff line numberDiff line change
    @@ -178,13 +178,14 @@ operators are only defined where they make sense; for example, they raise a
    178178
    single: __ge__() (instance method)
    179179

    180180
    Non-identical instances of a class normally compare as non-equal unless the
    181-
    class defines the :meth:`__eq__` method.
    181+
    class defines the :meth:`~object.__eq__` method.
    182182

    183183
    Instances of a class cannot be ordered with respect to other instances of the
    184184
    same class, or other types of object, unless the class defines enough of the
    185-
    methods :meth:`__lt__`, :meth:`__le__`, :meth:`__gt__`, and :meth:`__ge__` (in
    186-
    general, :meth:`__lt__` and :meth:`__eq__` are sufficient, if you want the
    187-
    conventional meanings of the comparison operators).
    185+
    methods :meth:`~object.__lt__`, :meth:`~object.__le__`, :meth:`~object.__gt__`, and
    186+
    :meth:`~object.__ge__` (in general, :meth:`~object.__lt__` and
    187+
    :meth:`~object.__eq__` are sufficient, if you want the conventional meanings of the
    188+
    comparison operators).
    188189

    189190
    The behavior of the :keyword:`is` and :keyword:`is not` operators cannot be
    190191
    customized; also they can be applied to any two objects and never raise an
    @@ -698,7 +699,7 @@ Hashing of numeric types
    698699
    ------------------------
    699700

    700701
    For numbers ``x`` and ``y``, possibly of different types, it's a requirement
    701-
    that ``hash(x) == hash(y)`` whenever ``x == y`` (see the :meth:`__hash__`
    702+
    that ``hash(x) == hash(y)`` whenever ``x == y`` (see the :meth:`~object.__hash__`
    702703
    method documentation for more details). For ease of implementation and
    703704
    efficiency across a variety of numeric types (including :class:`int`,
    704705
    :class:`float`, :class:`decimal.Decimal` and :class:`fractions.Fraction`)
    @@ -1334,7 +1335,7 @@ loops.
    13341335
    range(start, stop[, step])
    13351336

    13361337
    The arguments to the range constructor must be integers (either built-in
    1337-
    :class:`int` or any object that implements the ``__index__`` special
    1338+
    :class:`int` or any object that implements the :meth:`~object.__index__` special
    13381339
    method). If the *step* argument is omitted, it defaults to ``1``.
    13391340
    If the *start* argument is omitted, it defaults to ``0``.
    13401341
    If *step* is zero, :exc:`ValueError` is raised.
    @@ -4793,9 +4794,9 @@ their implementation of the context management protocol. See the
    47934794
    Python's :term:`generator`\s and the :class:`contextlib.contextmanager` decorator
    47944795
    provide a convenient way to implement these protocols. If a generator function is
    47954796
    decorated with the :class:`contextlib.contextmanager` decorator, it will return a
    4796-
    context manager implementing the necessary :meth:`__enter__` and
    4797-
    :meth:`__exit__` methods, rather than the iterator produced by an undecorated
    4798-
    generator function.
    4797+
    context manager implementing the necessary :meth:`~contextmanager.__enter__` and
    4798+
    :meth:`~contextmanager.__exit__` methods, rather than the iterator produced by an
    4799+
    undecorated generator function.
    47994800

    48004801
    Note that there is no specific slot for any of these methods in the type
    48014802
    structure for Python objects in the Python/C API. Extension types wanting to

    Doc/library/types.rst

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -312,7 +312,7 @@ Standard names are defined for the following types:
    312312
    This type can now be subclassed.
    313313

    314314

    315-
    .. data:: UnionType
    315+
    .. class:: UnionType
    316316

    317317
    The type of :ref:`union type expressions<types-union>`.
    318318

    Doc/reference/datamodel.rst

    Lines changed: 9 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1823,7 +1823,7 @@ Class Binding
    18231823

    18241824
    Super Binding
    18251825
    A dotted lookup such as ``super(A, a).x`` searches
    1826-
    ``obj.__class__.__mro__`` for a base class ``B`` following ``A`` and then
    1826+
    ``a.__class__.__mro__`` for a base class ``B`` following ``A`` and then
    18271827
    returns ``B.__dict__['x'].__get__(a, A)``. If not a descriptor, ``x`` is
    18281828
    returned unchanged.
    18291829

    @@ -1843,15 +1843,19 @@ Super Binding
    18431843
    x = 999
    18441844

    18451845
    def m(self):
    1846-
    'Demonstrate these two calls are equivalent'
    1847-
    result1 = super(A, a).x
    1848-
    result2 = B.__dict__['x'].__get__(a, A)
    1846+
    'Demonstrate these two descriptor invocations are equivalent'
    1847+
    result1 = super(A, self).x
    1848+
    result2 = B.__dict__['x'].__get__(self, A)
    18491849
    return result1 == result2
    18501850

    18511851
    .. doctest::
    18521852
    :hide:
    18531853

    18541854
    >>> a = A()
    1855+
    >>> a.__class__.__mro__.index(B) > a.__class__.__mro__.index(A)
    1856+
    True
    1857+
    >>> super(A, a).x == B.__dict__['x'].__get__(a, A)
    1858+
    True
    18551859
    >>> a.m()
    18561860
    True
    18571861

    @@ -2327,7 +2331,7 @@ called::
    23272331
    from inspect import isclass
    23282332

    23292333
    def subscribe(obj, x):
    2330-
    """Return the result of the expression `obj[x]`"""
    2334+
    """Return the result of the expression 'obj[x]'"""
    23312335

    23322336
    class_of_obj = type(obj)
    23332337

    Doc/tools/susp-ignored.csv

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -369,7 +369,6 @@ whatsnew/changelog,,::,default::DeprecationWarning
    369369
    library/importlib.metadata,,:main,"EntryPoint(name='wheel', value='wheel.cli:main', group='console_scripts')"
    370370
    library/importlib.metadata,,`,loading the metadata for packages for the indicated ``context``.
    371371
    library/re,,`,"`"
    372-
    using/configure,84,:db2,=db1:db2:...
    373372
    library/typing,,`,# Type of ``val`` is narrowed to ``str``
    374373
    library/typing,,`,"# Else, type of ``val`` is narrowed to ``float``."
    375374
    library/typing,,`,# Type of ``val`` is narrowed to ``list[str]``.
    @@ -380,4 +379,5 @@ library/tkinter,,::,"grid [ttk::button .frm.btn -text ""Quit"" -command ""destro
    380379
    library/tkinter,,::,ttk::frame
    381380
    library/tkinter,,::,ttk::button
    382381
    library/tkinter,,::,ttk::widget
    383-
    reference/datamodel,2285,`,"""""""Return the result of the expression `obj[x]`"""""""
    382+
    whatsnew/changelog,305,::,Lib/email/mime/nonmultipart.py::MIMENonMultipart
    383+
    whatsnew/changelog,308,::,Lib/ctypes/test/test_functions.py::test_mro

    Doc/using/configure.rst

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -80,7 +80,7 @@ General Options
    8080

    8181
    .. versionadded:: 3.9
    8282

    83-
    .. cmdoption:: --with-dbmliborder=db1:db2:...
    83+
    .. cmdoption:: --with-dbmliborder=<list of backend names>
    8484

    8585
    Override order to check db backends for the :mod:`dbm` module
    8686

    Doc/whatsnew/3.10.rst

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1173,7 +1173,7 @@ Highlight the new :ref:`soft keywords <soft-keywords>` :keyword:`match`,
    11731173
    :keyword:`case <match>`, and :keyword:`_ <wildcard-patterns>` in
    11741174
    pattern-matching statements. However, this highlighting is not perfect
    11751175
    and will be incorrect in some rare cases, including some ``_``-s in
    1176-
    ``case`` patterns. (Contributed by Tal Einat in bpo-44010.)
    1176+
    ``case`` patterns. (Contributed by Tal Einat in :issue:`44010`.)
    11771177
    11781178
    importlib.metadata
    11791179
    ------------------

    Doc/whatsnew/3.11.rst

    Lines changed: 18 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -329,6 +329,14 @@ unicodedata
    329329
    * The Unicode database has been updated to version 14.0.0. (:issue:`45190`).
    330330

    331331

    332+
    fcntl
    333+
    -----
    334+
    335+
    * On FreeBSD, the :attr:`F_DUP2FD` and :attr:`F_DUP2FD_CLOEXEC` flags respectively
    336+
    are supported, the former equals to ``dup2`` usage while the latter set
    337+
    the ``FD_CLOEXEC`` flag in addition.
    338+
    339+
    332340
    Optimizations
    333341
    =============
    334342

    @@ -618,6 +626,10 @@ New Features
    618626
    fields of the result from the exception instance (the ``value`` field).
    619627
    (Contributed by Irit Katriel in :issue:`45711`.)
    620628

    629+
    * Added the :c:data:`Py_Version` constant which bears the same value as
    630+
    :c:macro:`PY_VERSION_HEX`.
    631+
    (Contributed by Gabriele N. Tornetta in :issue:`43931`.)
    632+
    621633

    622634
    Porting to Python 3.11
    623635
    ----------------------
    @@ -715,6 +727,12 @@ Porting to Python 3.11
    715727
    been included directly, consider including ``Python.h`` instead.
    716728
    (Contributed by Victor Stinner in :issue:`35134`.)
    717729

    730+
    * The :c:func:`PyUnicode_CHECK_INTERNED` macro has been excluded from the
    731+
    limited C API. It was never usable there, because it used internal structures
    732+
    which are not available in the limited C API.
    733+
    (Contributed by Victor Stinner in :issue:`46007`.)
    734+
    735+
    718736
    Deprecated
    719737
    ----------
    720738

    Include/cpython/unicodeobject.h

    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -279,6 +279,10 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
    279279
    #define SSTATE_INTERNED_MORTAL 1
    280280
    #define SSTATE_INTERNED_IMMORTAL 2
    281281

    282+
    /* Use only if you know it's a string */
    283+
    #define PyUnicode_CHECK_INTERNED(op) \
    284+
    (((PyASCIIObject *)(op))->state.interned)
    285+
    282286
    /* Return true if the string contains only ASCII characters, or 0 if not. The
    283287
    string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
    284288
    ready. */

    Include/internal/pycore_bytesobject.h

    Lines changed: 30 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,30 @@
    1+
    #ifndef Py_INTERNAL_BYTESOBJECT_H
    2+
    #define Py_INTERNAL_BYTESOBJECT_H
    3+
    #ifdef __cplusplus
    4+
    extern "C" {
    5+
    #endif
    6+
    7+
    #ifndef Py_BUILD_CORE
    8+
    # error "this header requires Py_BUILD_CORE define"
    9+
    #endif
    10+
    11+
    12+
    /* runtime lifecycle */
    13+
    14+
    extern PyStatus _PyBytes_InitGlobalObjects(PyInterpreterState *);
    15+
    extern PyStatus _PyBytes_InitTypes(PyInterpreterState *);
    16+
    extern void _PyBytes_Fini(PyInterpreterState *);
    17+
    18+
    19+
    /* other API */
    20+
    21+
    struct _Py_bytes_state {
    22+
    PyObject *empty_string;
    23+
    PyBytesObject *characters[256];
    24+
    };
    25+
    26+
    27+
    #ifdef __cplusplus
    28+
    }
    29+
    #endif
    30+
    #endif /* !Py_INTERNAL_BYTESOBJECT_H */

    Include/internal/pycore_context.h

    Lines changed: 26 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -7,6 +7,32 @@
    77

    88
    #include "pycore_hamt.h" /* PyHamtObject */
    99

    10+
    11+
    /* runtime lifecycle */
    12+
    13+
    PyStatus _PyContext_InitTypes(PyInterpreterState *);
    14+
    void _PyContext_Fini(PyInterpreterState *);
    15+
    16+
    17+
    /* other API */
    18+
    19+
    #ifndef WITH_FREELISTS
    20+
    // without freelists
    21+
    # define PyContext_MAXFREELIST 0
    22+
    #endif
    23+
    24+
    #ifndef PyContext_MAXFREELIST
    25+
    # define PyContext_MAXFREELIST 255
    26+
    #endif
    27+
    28+
    struct _Py_context_state {
    29+
    #if PyContext_MAXFREELIST > 0
    30+
    // List of free PyContext objects
    31+
    PyContext *freelist;
    32+
    int numfree;
    33+
    #endif
    34+
    };
    35+
    1036
    struct _pycontextobject {
    1137
    PyObject_HEAD
    1238
    PyContext *ctx_prev;
    @@ -36,7 +62,4 @@ struct _pycontexttokenobject {
    3662
    };
    3763

    3864

    39-
    int _PyContext_Init(void);
    40-
    void _PyContext_Fini(PyInterpreterState *interp);
    41-
    4265
    #endif /* !Py_INTERNAL_CONTEXT_H */

    Include/internal/pycore_dict.h

    Lines changed: 26 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -10,6 +10,32 @@ extern "C" {
    1010
    #endif
    1111

    1212

    13+
    /* runtime lifecycle */
    14+
    15+
    extern void _PyDict_Fini(PyInterpreterState *interp);
    16+
    17+
    18+
    /* other API */
    19+
    20+
    #ifndef WITH_FREELISTS
    21+
    // without freelists
    22+
    # define PyDict_MAXFREELIST 0
    23+
    #endif
    24+
    25+
    #ifndef PyDict_MAXFREELIST
    26+
    # define PyDict_MAXFREELIST 80
    27+
    #endif
    28+
    29+
    struct _Py_dict_state {
    30+
    #if PyDict_MAXFREELIST > 0
    31+
    /* Dictionary reuse scheme to save calls to malloc and free */
    32+
    PyDictObject *free_list[PyDict_MAXFREELIST];
    33+
    int numfree;
    34+
    PyDictKeysObject *keys_free_list[PyDict_MAXFREELIST];
    35+
    int keys_numfree;
    36+
    #endif
    37+
    };
    38+
    1339
    typedef struct {
    1440
    /* Cached hash code of me_key. */
    1541
    Py_hash_t me_hash;

    0 commit comments

    Comments
     (0)
    0