Skip to content

Commit ec50130

Browse files
authored
Merge branch 'main' into dev_143414
2 parents b80bce1 + 3e9a5b0 commit ec50130

File tree

93 files changed

+2906
-1570
lines changed

Some content is hidden

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

93 files changed

+2906
-1570
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ Lib/test/test_stable_abi_ctypes.py generated
9494
Lib/test/test_zoneinfo/data/*.json generated
9595
Lib/token.py generated
9696
Misc/sbom.spdx.json generated
97+
Modules/_testinternalcapi/test_cases.c.h generated
98+
Modules/_testinternalcapi/test_targets.h generated
9799
Objects/typeslots.inc generated
98100
PC/python3dll.c generated
99101
Parser/parser.c generated

Doc/c-api/module.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,9 @@ or code that creates modules dynamically.
10211021
``PyModuleDef`` (such as when using :ref:`multi-phase-initialization`,
10221022
``PyModule_Create``, or ``PyModule_FromDefAndSpec``).
10231023
1024+
Return ``0`` on success.
1025+
Return ``-1`` with an exception set on error.
1026+
10241027
.. versionadded:: 3.5
10251028
10261029
.. c:function:: int PyUnstable_Module_SetGIL(PyObject *module, void *gil)

Doc/faq/programming.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,13 +1226,13 @@ This converts the list into a set, thereby removing duplicates, and then back
12261226
into a list.
12271227

12281228

1229-
How do you remove multiple items from a list
1230-
--------------------------------------------
1229+
How do you remove multiple items from a list?
1230+
---------------------------------------------
12311231

12321232
As with removing duplicates, explicitly iterating in reverse with a
12331233
delete condition is one possibility. However, it is easier and faster
12341234
to use slice replacement with an implicit or explicit forward iteration.
1235-
Here are three variations.::
1235+
Here are three variations::
12361236

12371237
mylist[:] = filter(keep_function, mylist)
12381238
mylist[:] = (x for x in mylist if keep_condition)

Doc/library/base64.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ POST request.
7373

7474

7575
.. function:: b64decode(s, altchars=None, validate=False)
76+
b64decode(s, altchars=None, validate=True, *, ignorechars)
7677
7778
Decode the Base64 encoded :term:`bytes-like object` or ASCII string
7879
*s* and return the decoded :class:`bytes`.
@@ -84,11 +85,17 @@ POST request.
8485
A :exc:`binascii.Error` exception is raised
8586
if *s* is incorrectly padded.
8687

87-
If *validate* is false (the default), characters that are neither
88+
If *ignorechars* is specified, it should be a :term:`bytes-like object`
89+
containing characters to ignore from the input when *validate* is true.
90+
The default value of *validate* is ``True`` if *ignorechars* is specified,
91+
``False`` otherwise.
92+
93+
If *validate* is false, characters that are neither
8894
in the normal base-64 alphabet nor the alternative alphabet are
8995
discarded prior to the padding check, but the ``+`` and ``/`` characters
9096
keep their meaning if they are not in *altchars* (they will be discarded
9197
in future Python versions).
98+
9299
If *validate* is true, these non-alphabet characters in the input
93100
result in a :exc:`binascii.Error`.
94101

@@ -99,6 +106,10 @@ POST request.
99106
is now deprecated.
100107

101108

109+
.. versionchanged:: next
110+
Added the *ignorechars* parameter.
111+
112+
102113
.. function:: standard_b64encode(s)
103114

104115
Encode :term:`bytes-like object` *s* using the standard Base64 alphabet
@@ -254,8 +265,7 @@ Refer to the documentation of the individual functions for more information.
254265
*adobe* controls whether the input sequence is in Adobe Ascii85 format
255266
(i.e. is framed with <~ and ~>).
256267

257-
*ignorechars* should be a :term:`bytes-like object` or ASCII string
258-
containing characters to ignore
268+
*ignorechars* should be a byte string containing characters to ignore
259269
from the input. This should only contain whitespace characters, and by
260270
default contains all whitespace characters in ASCII.
261271

Doc/library/binascii.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,16 @@ The :mod:`binascii` module defines the following functions:
4949

5050

5151
.. function:: a2b_base64(string, /, *, strict_mode=False)
52+
a2b_base64(string, /, *, strict_mode=True, ignorechars)
5253
5354
Convert a block of base64 data back to binary and return the binary data. More
5455
than one line may be passed at a time.
5556

57+
If *ignorechars* is specified, it should be a :term:`bytes-like object`
58+
containing characters to ignore from the input when *strict_mode* is true.
59+
The default value of *strict_mode* is ``True`` if *ignorechars* is specified,
60+
``False`` otherwise.
61+
5662
If *strict_mode* is true, only valid base64 data will be converted. Invalid base64
5763
data will raise :exc:`binascii.Error`.
5864

@@ -66,6 +72,9 @@ The :mod:`binascii` module defines the following functions:
6672
.. versionchanged:: 3.11
6773
Added the *strict_mode* parameter.
6874

75+
.. versionchanged:: next
76+
Added the *ignorechars* parameter.
77+
6978

7079
.. function:: b2a_base64(data, *, wrapcol=0, newline=True)
7180

Doc/library/contextvars.rst

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,32 @@ Context Variables
7777
to restore the variable to its previous value via the
7878
:meth:`ContextVar.reset` method.
7979

80+
For convenience, the token object can be used as a context manager
81+
to avoid calling :meth:`ContextVar.reset` manually::
82+
83+
var = ContextVar('var', default='default value')
84+
85+
with var.set('new value'):
86+
assert var.get() == 'new value'
87+
88+
assert var.get() == 'default value'
89+
90+
It is a shorthand for::
91+
92+
var = ContextVar('var', default='default value')
93+
94+
token = var.set('new value')
95+
try:
96+
assert var.get() == 'new value'
97+
finally:
98+
var.reset(token)
99+
100+
assert var.get() == 'default value'
101+
102+
.. versionadded:: 3.14
103+
104+
Added support for using tokens as context managers.
105+
80106
.. method:: reset(token)
81107

82108
Reset the context variable to the value it had before the
@@ -101,16 +127,8 @@ Context Variables
101127
the value of the variable to what it was before the corresponding
102128
*set*.
103129

104-
The token supports :ref:`context manager protocol <context-managers>`
105-
to restore the corresponding context variable value at the exit from
106-
:keyword:`with` block::
107-
108-
var = ContextVar('var', default='default value')
109-
110-
with var.set('new value'):
111-
assert var.get() == 'new value'
112-
113-
assert var.get() == 'default value'
130+
Tokens support the :ref:`context manager protocol <context-managers>`
131+
to automatically reset context variables. See :meth:`ContextVar.set`.
114132

115133
.. versionadded:: 3.14
116134

Doc/library/importlib.rst

Lines changed: 0 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -596,172 +596,6 @@ ABC hierarchy::
596596
itself does not end in ``__init__``.
597597

598598

599-
.. class:: ResourceReader
600-
601-
*Superseded by TraversableResources*
602-
603-
An :term:`abstract base class` to provide the ability to read
604-
*resources*.
605-
606-
From the perspective of this ABC, a *resource* is a binary
607-
artifact that is shipped within a package. Typically this is
608-
something like a data file that lives next to the ``__init__.py``
609-
file of the package. The purpose of this class is to help abstract
610-
out the accessing of such data files so that it does not matter if
611-
the package and its data file(s) are stored e.g. in a zip file
612-
versus on the file system.
613-
614-
For any of methods of this class, a *resource* argument is
615-
expected to be a :term:`path-like object` which represents
616-
conceptually just a file name. This means that no subdirectory
617-
paths should be included in the *resource* argument. This is
618-
because the location of the package the reader is for, acts as the
619-
"directory". Hence the metaphor for directories and file
620-
names is packages and resources, respectively. This is also why
621-
instances of this class are expected to directly correlate to
622-
a specific package (instead of potentially representing multiple
623-
packages or a module).
624-
625-
Loaders that wish to support resource reading are expected to
626-
provide a method called ``get_resource_reader(fullname)`` which
627-
returns an object implementing this ABC's interface. If the module
628-
specified by fullname is not a package, this method should return
629-
:const:`None`. An object compatible with this ABC should only be
630-
returned when the specified module is a package.
631-
632-
.. versionadded:: 3.7
633-
634-
.. deprecated-removed:: 3.12 3.14
635-
Use :class:`importlib.resources.abc.TraversableResources` instead.
636-
637-
.. method:: open_resource(resource)
638-
:abstractmethod:
639-
640-
Returns an opened, :term:`file-like object` for binary reading
641-
of the *resource*.
642-
643-
If the resource cannot be found, :exc:`FileNotFoundError` is
644-
raised.
645-
646-
.. method:: resource_path(resource)
647-
:abstractmethod:
648-
649-
Returns the file system path to the *resource*.
650-
651-
If the resource does not concretely exist on the file system,
652-
raise :exc:`FileNotFoundError`.
653-
654-
.. method:: is_resource(name)
655-
:abstractmethod:
656-
657-
Returns ``True`` if the named *name* is considered a resource.
658-
:exc:`FileNotFoundError` is raised if *name* does not exist.
659-
660-
.. method:: contents()
661-
:abstractmethod:
662-
663-
Returns an :term:`iterable` of strings over the contents of
664-
the package. Do note that it is not required that all names
665-
returned by the iterator be actual resources, e.g. it is
666-
acceptable to return names for which :meth:`is_resource` would
667-
be false.
668-
669-
Allowing non-resource names to be returned is to allow for
670-
situations where how a package and its resources are stored
671-
are known a priori and the non-resource names would be useful.
672-
For instance, returning subdirectory names is allowed so that
673-
when it is known that the package and resources are stored on
674-
the file system then those subdirectory names can be used
675-
directly.
676-
677-
The abstract method returns an iterable of no items.
678-
679-
680-
.. class:: Traversable
681-
682-
An object with a subset of :class:`pathlib.Path` methods suitable for
683-
traversing directories and opening files.
684-
685-
For a representation of the object on the file-system, use
686-
:meth:`importlib.resources.as_file`.
687-
688-
.. versionadded:: 3.9
689-
690-
.. deprecated-removed:: 3.12 3.14
691-
Use :class:`importlib.resources.abc.Traversable` instead.
692-
693-
.. attribute:: name
694-
695-
Abstract. The base name of this object without any parent references.
696-
697-
.. method:: iterdir()
698-
:abstractmethod:
699-
700-
Yield ``Traversable`` objects in ``self``.
701-
702-
.. method:: is_dir()
703-
:abstractmethod:
704-
705-
Return ``True`` if ``self`` is a directory.
706-
707-
.. method:: is_file()
708-
:abstractmethod:
709-
710-
Return ``True`` if ``self`` is a file.
711-
712-
.. method:: joinpath(child)
713-
:abstractmethod:
714-
715-
Return Traversable child in ``self``.
716-
717-
.. method:: __truediv__(child)
718-
:abstractmethod:
719-
720-
Return ``Traversable`` child in ``self``.
721-
722-
.. method:: open(mode='r', *args, **kwargs)
723-
:abstractmethod:
724-
725-
*mode* may be 'r' or 'rb' to open as text or binary. Return a handle
726-
suitable for reading (same as :attr:`pathlib.Path.open`).
727-
728-
When opening as text, accepts encoding parameters such as those
729-
accepted by :class:`io.TextIOWrapper`.
730-
731-
.. method:: read_bytes()
732-
733-
Read contents of ``self`` as bytes.
734-
735-
.. method:: read_text(encoding=None)
736-
737-
Read contents of ``self`` as text.
738-
739-
740-
.. class:: TraversableResources
741-
742-
An abstract base class for resource readers capable of serving
743-
the :meth:`importlib.resources.files` interface. Subclasses
744-
:class:`importlib.resources.abc.ResourceReader` and provides
745-
concrete implementations of the :class:`importlib.resources.abc.ResourceReader`'s
746-
abstract methods. Therefore, any loader supplying
747-
:class:`importlib.abc.TraversableResources` also supplies ResourceReader.
748-
749-
Loaders that wish to support resource reading are expected to
750-
implement this interface.
751-
752-
.. versionadded:: 3.9
753-
754-
.. deprecated-removed:: 3.12 3.14
755-
Use :class:`importlib.resources.abc.TraversableResources` instead.
756-
757-
.. method:: files()
758-
:abstractmethod:
759-
760-
Returns a :class:`importlib.resources.abc.Traversable` object for the loaded
761-
package.
762-
763-
764-
765599
:mod:`importlib.machinery` -- Importers and path hooks
766600
------------------------------------------------------
767601

Doc/library/inspect.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
524524

525525
.. versionchanged:: 3.13
526526
Functions wrapped in :func:`functools.partialmethod` now return ``True``
527-
if the wrapped function is a :term:`coroutine function`.
527+
if the wrapped function is a :term:`asynchronous generator` function.
528528

529529
.. function:: isasyncgen(object)
530530

Doc/library/msvcrt.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
.. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
99

10+
**Source code:** :source:`PC/msvcrtmodule.c`
11+
1012
--------------
1113

1214
These functions provide access to some useful capabilities on Windows platforms.

Doc/library/os.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4262,7 +4262,7 @@ features:
42624262
import os
42634263

42644264
# semaphore with start value '1'
4265-
fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFC_CLOEXEC)
4265+
fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFD_CLOEXEC)
42664266
try:
42674267
# acquire semaphore
42684268
v = os.eventfd_read(fd)

0 commit comments

Comments
 (0)