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

Skip to content

Commit f7b6662

Browse files
committed
Merge branch 'main' into unpack_keywords_bugfix
# Conflicts: # Lib/test/clinic.test
2 parents bbad2bb + e8259e0 commit f7b6662

File tree

108 files changed

+3708
-6897
lines changed
  • Misc/NEWS.d/next
  • Modules
  • Objects
  • PC/clinic
  • Parser
  • Python
  • Tools
  • Some content is hidden

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

    108 files changed

    +3708
    -6897
    lines changed

    Doc/library/asyncio-runner.rst

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -75,7 +75,9 @@ Runner context manager
    7575
    :ref:`asyncio-debug-mode` settings.
    7676

    7777
    *loop_factory* could be used for overriding the loop creation.
    78-
    :func:`asyncio.new_event_loop` is used if ``None``.
    78+
    It is the responsibility of the *loop_factory* to set the created loop as the
    79+
    current one. By default :func:`asyncio.new_event_loop` is used and set as
    80+
    current event loop with :func:`asyncio.set_event_loop` if *loop_factory* is ``None``.
    7981

    8082
    Basically, :func:`asyncio.run()` example can be rewritten with the runner usage::
    8183

    Doc/library/grp.rst

    Lines changed: 2 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -45,9 +45,8 @@ It defines the following items:
    4545
    Return the group database entry for the given numeric group ID. :exc:`KeyError`
    4646
    is raised if the entry asked for cannot be found.
    4747

    48-
    .. deprecated:: 3.6
    49-
    Since Python 3.6 the support of non-integer arguments like floats or
    50-
    strings in :func:`getgrgid` is deprecated.
    48+
    .. versionchanged:: 3.10
    49+
    :exc:`TypeError` is raised for non-integer arguments like floats or strings.
    5150

    5251
    .. function:: getgrnam(name)
    5352

    Doc/library/typing.rst

    Lines changed: 5 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1825,6 +1825,9 @@ These are not used in annotations. They are building blocks for declaring types.
    18251825
    True
    18261826

    18271827
    .. attribute:: __required_keys__
    1828+
    1829+
    .. versionadded:: 3.9
    1830+
    18281831
    .. attribute:: __optional_keys__
    18291832

    18301833
    ``Point2D.__required_keys__`` and ``Point2D.__optional_keys__`` return
    @@ -1852,6 +1855,8 @@ These are not used in annotations. They are building blocks for declaring types.
    18521855
    >>> Point3D.__optional_keys__ == frozenset({'x', 'y'})
    18531856
    True
    18541857

    1858+
    .. versionadded:: 3.9
    1859+
    18551860
    See :pep:`589` for more examples and detailed rules of using ``TypedDict``.
    18561861

    18571862
    .. versionadded:: 3.8

    Doc/whatsnew/3.11.rst

    Lines changed: 59 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -49,13 +49,14 @@ This article explains the new features in Python 3.11, compared to 3.10.
    4949

    5050
    For full details, see the :ref:`changelog <changelog>`.
    5151

    52+
    5253
    Summary -- Release highlights
    5354
    =============================
    5455

    5556
    .. This section singles out the most important changes in Python 3.11.
    5657
    Brevity is key.
    5758
    58-
    - Python 3.11 is up to 10-60% faster than Python 3.10. On average, we measured a
    59+
    - Python 3.11 is between 10-60% faster than Python 3.10. On average, we measured a
    5960
    1.25x speedup on the standard benchmark suite. See `Faster CPython`_ for details.
    6061

    6162
    .. PEP-sized items next.
    @@ -65,18 +66,35 @@ New syntax features:
    6566
    * :pep:`654`: Exception Groups and ``except*``.
    6667
    (Contributed by Irit Katriel in :issue:`45292`.)
    6768

    69+
    New built-in features:
    70+
    71+
    * :pep:`678`: Enriching Exceptions with Notes.
    72+
    73+
    New standard library modules:
    74+
    75+
    * :pep:`680`: ``tomllib`` — Support for Parsing TOML in the Standard Library.
    76+
    77+
    Interpreter improvements:
    78+
    79+
    * :pep:`657`: Include Fine Grained Error Locations in Tracebacks.
    80+
    * New :option:`-P` command line option and :envvar:`PYTHONSAFEPATH` environment
    81+
    variable to disable automatically prepending a potentially unsafe path
    82+
    (the working dir or script directory, depending on invocation)
    83+
    to :data:`sys.path`.
    84+
    6885
    New typing features:
    6986

    7087
    * :pep:`646`: Variadic generics.
    7188
    * :pep:`655`: Marking individual TypedDict items as required or potentially missing.
    7289
    * :pep:`673`: ``Self`` type.
    7390
    * :pep:`675`: Arbitrary literal string type.
    91+
    * :pep:`681`: Data Class Transforms.
    7492

    75-
    Security improvements:
    93+
    Important deprecations, removals or restrictions:
    7694

    77-
    * New :option:`-P` command line option and :envvar:`PYTHONSAFEPATH` environment
    78-
    variable to not prepend a potentially unsafe path to :data:`sys.path` such as
    79-
    the current directory, the script's directory or an empty string.
    95+
    * :pep:`594`: Removing dead batteries from the standard library.
    96+
    * :pep:`624`: Remove ``Py_UNICODE`` encoder APIs.
    97+
    * :pep:`670`: Convert macros to functions in the Python C API.
    8098

    8199

    82100
    New Features
    @@ -158,8 +176,25 @@ The :option:`-X` ``no_debug_ranges`` option and the environment variable
    158176
    See :pep:`657` for more details. (Contributed by Pablo Galindo, Batuhan Taskaya
    159177
    and Ammar Askar in :issue:`43950`.)
    160178

    161-
    Exceptions can be enriched with notes (PEP 678)
    162-
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    179+
    180+
    PEP 654: Exception Groups and ``except*``
    181+
    -----------------------------------------
    182+
    183+
    :pep:`654` introduces language features that enable a program
    184+
    to raise and handle multiple unrelated exceptions simultaneously.
    185+
    The builtin types :exc:`ExceptionGroup` and :exc:`BaseExceptionGroup`
    186+
    make it possible to group exceptions and raise them together,
    187+
    and the new :keyword:`except* <except_star>` syntax generalizes
    188+
    :keyword:`except` to match subgroups of exception groups.
    189+
    190+
    See :pep:`654` for more details.
    191+
    192+
    (Contributed by Irit Katriel in :issue:`45292`. PEP written by
    193+
    Irit Katriel, Yury Selivanov and Guido van Rossum.)
    194+
    195+
    196+
    PEP 678: Exceptions can be enriched with notes
    197+
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    163198

    164199
    The :meth:`add_note` method was added to :exc:`BaseException`. It can be
    165200
    used to enrich exceptions with context information which is not available
    @@ -417,6 +452,12 @@ Other CPython Implementation Changes
    417452
    :data:`sys.path`. Otherwise, initialization will recalculate the path and replace
    418453
    any values added to ``module_search_paths``.
    419454

    455+
    * The output of the :option:`--help` option is changed to fit inside 50 lines and 80
    456+
    columns. Information about :ref:`Python environment variables <using-on-envvars>`
    457+
    and :option:`-X options <-X>` is available with the new :option:`--help-env` or
    458+
    :option:`--help-xoptions` flags, and with :option:`--help-all`.
    459+
    (Contributed by Éric Araujo in :issue:`46142`.)
    460+
    420461

    421462
    New Modules
    422463
    ===========
    @@ -454,6 +495,13 @@ asyncio
    454495
    holding a group of tasks that will wait for all of them upon exit.
    455496
    (Contributed by Yury Seliganov and others.)
    456497

    498+
    contextlib
    499+
    ----------
    500+
    501+
    Added non parallel-safe :func:`~contextlib.chdir` context manager to change
    502+
    the current working directory and then restore it on exit. Simple wrapper
    503+
    around :func:`~os.chdir`. (Contributed by Filipe Laíns in :issue:`25625`)
    504+
    457505
    datetime
    458506
    --------
    459507

    @@ -561,6 +609,10 @@ hashlib
    561609
    OpenSSL support.
    562610
    (Contributed by Christian Heimes in :issue:`47098`.)
    563611

    612+
    * Add :func:`hashlib.file_digest`, a helper function for efficient hashing
    613+
    of files or file-like objects.
    614+
    (Contributed by Christian Heimes in :gh:`89313`.)
    615+
    564616
    IDLE and idlelib
    565617
    ----------------
    566618

    Grammar/python.gram

    Lines changed: 4 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -287,9 +287,9 @@ params[arguments_ty]:
    287287

    288288
    parameters[arguments_ty]:
    289289
    | a=slash_no_default b[asdl_arg_seq*]=param_no_default* c=param_with_default* d=[star_etc] {
    290-
    _PyPegen_make_arguments(p, a, NULL, b, c, d) }
    290+
    CHECK_VERSION(arguments_ty, 8, "Positional-only parameters are", _PyPegen_make_arguments(p, a, NULL, b, c, d)) }
    291291
    | a=slash_with_default b=param_with_default* c=[star_etc] {
    292-
    _PyPegen_make_arguments(p, NULL, a, NULL, b, c) }
    292+
    CHECK_VERSION(arguments_ty, 8, "Positional-only parameters are", _PyPegen_make_arguments(p, NULL, a, NULL, b, c)) }
    293293
    | a[asdl_arg_seq*]=param_no_default+ b=param_with_default* c=[star_etc] {
    294294
    _PyPegen_make_arguments(p, NULL, NULL, a, b, c) }
    295295
    | a=param_with_default+ b=[star_etc] { _PyPegen_make_arguments(p, NULL, NULL, NULL, a, b)}
    @@ -830,9 +830,9 @@ lambda_params[arguments_ty]:
    830830
    #
    831831
    lambda_parameters[arguments_ty]:
    832832
    | a=lambda_slash_no_default b[asdl_arg_seq*]=lambda_param_no_default* c=lambda_param_with_default* d=[lambda_star_etc] {
    833-
    _PyPegen_make_arguments(p, a, NULL, b, c, d) }
    833+
    CHECK_VERSION(arguments_ty, 8, "Positional-only parameters are", _PyPegen_make_arguments(p, a, NULL, b, c, d)) }
    834834
    | a=lambda_slash_with_default b=lambda_param_with_default* c=[lambda_star_etc] {
    835-
    _PyPegen_make_arguments(p, NULL, a, NULL, b, c) }
    835+
    CHECK_VERSION(arguments_ty, 8, "Positional-only parameters are", _PyPegen_make_arguments(p, NULL, a, NULL, b, c)) }
    836836
    | a[asdl_arg_seq*]=lambda_param_no_default+ b=lambda_param_with_default* c=[lambda_star_etc] {
    837837
    _PyPegen_make_arguments(p, NULL, NULL, a, b, c) }
    838838
    | a=lambda_param_with_default+ b=[lambda_star_etc] { _PyPegen_make_arguments(p, NULL, NULL, NULL, a, b)}

    Include/internal/pycore_atomic.h

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -236,7 +236,7 @@ _Py_ANNOTATE_MEMORY_ORDER(const volatile void *address, _Py_memory_order order)
    236236
    in hardware they will fall back to a full memory barrier as well.
    237237
    238238
    This might affect performance but likely only in some very specific and
    239-
    hard to meassure scenario.
    239+
    hard to measure scenario.
    240240
    */
    241241
    #if defined(_M_IX86) || defined(_M_X64)
    242242
    typedef enum _Py_memory_order {

    Lib/dis.py

    Lines changed: 8 additions & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -394,7 +394,7 @@ def _get_name_info(name_index, get_name, **extrainfo):
    394394
    else:
    395395
    return UNKNOWN, ''
    396396

    397-
    def parse_varint(iterator):
    397+
    def _parse_varint(iterator):
    398398
    b = next(iterator)
    399399
    val = b & 63
    400400
    while b&64:
    @@ -403,16 +403,16 @@ def parse_varint(iterator):
    403403
    val |= b&63
    404404
    return val
    405405

    406-
    def parse_exception_table(code):
    406+
    def _parse_exception_table(code):
    407407
    iterator = iter(code.co_exceptiontable)
    408408
    entries = []
    409409
    try:
    410410
    while True:
    411-
    start = parse_varint(iterator)*2
    412-
    length = parse_varint(iterator)*2
    411+
    start = _parse_varint(iterator)*2
    412+
    length = _parse_varint(iterator)*2
    413413
    end = start + length
    414-
    target = parse_varint(iterator)*2
    415-
    dl = parse_varint(iterator)
    414+
    target = _parse_varint(iterator)*2
    415+
    dl = _parse_varint(iterator)
    416416
    depth = dl >> 1
    417417
    lasti = bool(dl&1)
    418418
    entries.append(_ExceptionTableEntry(start, end, target, depth, lasti))
    @@ -527,7 +527,7 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
    527527
    def disassemble(co, lasti=-1, *, file=None, show_caches=False, adaptive=False):
    528528
    """Disassemble a code object."""
    529529
    linestarts = dict(findlinestarts(co))
    530-
    exception_entries = parse_exception_table(co)
    530+
    exception_entries = _parse_exception_table(co)
    531531
    _disassemble_bytes(_get_code_array(co, adaptive),
    532532
    lasti, co._varname_from_oparg,
    533533
    co.co_names, co.co_consts, linestarts, file=file,
    @@ -717,7 +717,7 @@ def __init__(self, x, *, first_line=None, current_offset=None, show_caches=False
    717717
    self._linestarts = dict(findlinestarts(co))
    718718
    self._original_object = x
    719719
    self.current_offset = current_offset
    720-
    self.exception_entries = parse_exception_table(co)
    720+
    self.exception_entries = _parse_exception_table(co)
    721721
    self.show_caches = show_caches
    722722
    self.adaptive = adaptive
    723723

    Lib/pathlib.py

    Lines changed: 8 additions & 33 deletions
    Original file line numberDiff line numberDiff line change
    @@ -61,41 +61,16 @@ def __init__(self):
    6161
    self.join = self.sep.join
    6262

    6363
    def parse_parts(self, parts):
    64-
    parsed = []
    64+
    if not parts:
    65+
    return '', '', []
    6566
    sep = self.sep
    6667
    altsep = self.altsep
    67-
    drv = root = ''
    68-
    it = reversed(parts)
    69-
    for part in it:
    70-
    if not part:
    71-
    continue
    72-
    if altsep:
    73-
    part = part.replace(altsep, sep)
    74-
    drv, root, rel = self.splitroot(part)
    75-
    if sep in rel:
    76-
    for x in reversed(rel.split(sep)):
    77-
    if x and x != '.':
    78-
    parsed.append(sys.intern(x))
    79-
    else:
    80-
    if rel and rel != '.':
    81-
    parsed.append(sys.intern(rel))
    82-
    if drv or root:
    83-
    if not drv:
    84-
    # If no drive is present, try to find one in the previous
    85-
    # parts. This makes the result of parsing e.g.
    86-
    # ("C:", "/", "a") reasonably intuitive.
    87-
    for part in it:
    88-
    if not part:
    89-
    continue
    90-
    if altsep:
    91-
    part = part.replace(altsep, sep)
    92-
    drv = self.splitroot(part)[0]
    93-
    if drv:
    94-
    break
    95-
    break
    96-
    if drv or root:
    97-
    parsed.append(drv + root)
    98-
    parsed.reverse()
    68+
    path = self.pathmod.join(*parts)
    69+
    if altsep:
    70+
    path = path.replace(altsep, sep)
    71+
    drv, root, rel = self.splitroot(path)
    72+
    unfiltered_parsed = [drv + root] + rel.split(sep)
    73+
    parsed = [sys.intern(x) for x in unfiltered_parsed if x and x != '.']
    9974
    return drv, root, parsed
    10075

    10176
    def join_parsed_parts(self, drv, root, parts, drv2, root2, parts2):

    0 commit comments

    Comments
     (0)
    0