Skip to content

Commit 2036d0a

Browse files
committed
Merge branch 'main' into issue-91602
2 parents 4de91be + b69548a commit 2036d0a

File tree

80 files changed

+3316
-420
lines changed

Some content is hidden

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

80 files changed

+3316
-420
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Lib/test/test_type_*.py @JelleZijlstra
4242
Lib/test/test_capi/test_misc.py @markshannon @gvanrossum
4343
Tools/c-analyzer/ @ericsnowcurrently
4444

45+
# dbm
46+
**/*dbm* @corona10 @erlend-aasland @serhiy-storchaka
47+
4548
# Exceptions
4649
Lib/traceback.py @iritkatriel
4750
Lib/test/test_except*.py @iritkatriel

Doc/c-api/structures.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,11 @@ The following flags can be used with :c:member:`PyMemberDef.flags`:
551551
from ``PyObject``.
552552
553553
Can only be used as part of :c:member:`Py_tp_members <PyTypeObject.tp_members>`
554-
:c:type:`slot <PyTypeSlot>` when creating a class using negative
554+
:c:type:`slot <PyType_Slot>` when creating a class using negative
555555
:c:member:`~PyType_Spec.basicsize`.
556556
It is mandatory in that case.
557557
558-
This flag is only used in :c:type:`PyTypeSlot`.
558+
This flag is only used in :c:type:`PyType_Slot`.
559559
When setting :c:member:`~PyTypeObject.tp_members` during
560560
class creation, Python clears it and sets
561561
:c:member:`PyMemberDef.offset` to the offset from the ``PyObject`` struct.
@@ -693,7 +693,8 @@ Defining Getters and Setters
693693
694694
.. c:member:: setter set
695695
696-
Optional C function to set or delete the attribute, if omitted the attribute is readonly.
696+
Optional C function to set or delete the attribute.
697+
If ``NULL``, the attribute is read-only.
697698
698699
.. c:member:: const char* doc
699700
@@ -703,18 +704,18 @@ Defining Getters and Setters
703704
704705
Optional function pointer, providing additional data for getter and setter.
705706
706-
The ``get`` function takes one :c:expr:`PyObject*` parameter (the
707-
instance) and a function pointer (the associated ``closure``)::
707+
.. c:type:: PyObject *(*getter)(PyObject *, void *)
708708
709-
typedef PyObject *(*getter)(PyObject *, void *);
709+
The ``get`` function takes one :c:expr:`PyObject*` parameter (the
710+
instance) and a function pointer (the associated ``closure``):
710711
711712
It should return a new reference on success or ``NULL`` with a set exception
712713
on failure.
713714
714-
``set`` functions take two :c:expr:`PyObject*` parameters (the instance and
715-
the value to be set) and a function pointer (the associated ``closure``)::
715+
.. c:type:: int (*setter)(PyObject *, PyObject *, void *)
716716
717-
typedef int (*setter)(PyObject *, PyObject *, void *);
717+
``set`` functions take two :c:expr:`PyObject*` parameters (the instance and
718+
the value to be set) and a function pointer (the associated ``closure``):
718719
719720
In case the attribute should be deleted the second parameter is ``NULL``.
720721
Should return ``0`` on success or ``-1`` with a set exception on failure.

Doc/library/concurrent.futures.rst

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ to a :class:`ProcessPoolExecutor` will result in deadlock.
275275

276276
.. versionchanged:: 3.3
277277
When one of the worker processes terminates abruptly, a
278-
:exc:`BrokenProcessPool` error is now raised. Previously, behaviour
278+
:exc:`~concurrent.futures.process.BrokenProcessPool` error is now raised.
279+
Previously, behaviour
279280
was undefined but operations on the executor or its futures would often
280281
freeze or deadlock.
281282

@@ -493,23 +494,22 @@ Module Functions
493494
*return_when* indicates when this function should return. It must be one of
494495
the following constants:
495496

496-
.. tabularcolumns:: |l|L|
497-
498-
+-----------------------------+----------------------------------------+
499-
| Constant | Description |
500-
+=============================+========================================+
501-
| :const:`FIRST_COMPLETED` | The function will return when any |
502-
| | future finishes or is cancelled. |
503-
+-----------------------------+----------------------------------------+
504-
| :const:`FIRST_EXCEPTION` | The function will return when any |
505-
| | future finishes by raising an |
506-
| | exception. If no future raises an |
507-
| | exception then it is equivalent to |
508-
| | :const:`ALL_COMPLETED`. |
509-
+-----------------------------+----------------------------------------+
510-
| :const:`ALL_COMPLETED` | The function will return when all |
511-
| | futures finish or are cancelled. |
512-
+-----------------------------+----------------------------------------+
497+
.. list-table::
498+
:header-rows: 1
499+
500+
* - Constant
501+
- Description
502+
503+
* - .. data:: FIRST_COMPLETED
504+
- The function will return when any future finishes or is cancelled.
505+
506+
* - .. data:: FIRST_EXCEPTION
507+
- The function will return when any future finishes by raising an
508+
exception. If no future raises an exception
509+
then it is equivalent to :const:`ALL_COMPLETED`.
510+
511+
* - .. data:: ALL_COMPLETED
512+
- The function will return when all futures finish or are cancelled.
513513

514514
.. function:: as_completed(fs, timeout=None)
515515

@@ -570,7 +570,8 @@ Exception classes
570570
.. exception:: BrokenThreadPool
571571

572572
Derived from :exc:`~concurrent.futures.BrokenExecutor`, this exception
573-
class is raised when one of the workers of a :class:`ThreadPoolExecutor`
573+
class is raised when one of the workers
574+
of a :class:`~concurrent.futures.ThreadPoolExecutor`
574575
has failed initializing.
575576

576577
.. versionadded:: 3.7
@@ -581,7 +582,8 @@ Exception classes
581582

582583
Derived from :exc:`~concurrent.futures.BrokenExecutor` (formerly
583584
:exc:`RuntimeError`), this exception class is raised when one of the
584-
workers of a :class:`ProcessPoolExecutor` has terminated in a non-clean
585+
workers of a :class:`~concurrent.futures.ProcessPoolExecutor`
586+
has terminated in a non-clean
585587
fashion (for example, if it was killed from the outside).
586588

587589
.. versionadded:: 3.3

Doc/library/dis.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,8 @@ operations on it as if it was a Python list. The top of the stack corresponds to
546546

547547
.. opcode:: END_FOR
548548

549-
Removes the top two values from the stack.
550-
Equivalent to ``POP_TOP``; ``POP_TOP``.
549+
Removes the top-of-stack item.
550+
Equivalent to ``POP_TOP``.
551551
Used to clean up at the end of loops, hence the name.
552552

553553
.. versionadded:: 3.12

Doc/library/ftplib.rst

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ FTP objects
7878
A 2-tuple ``(host, port)`` for the socket to bind to as its
7979
source address before connecting.
8080

81+
.. |param_doc_encoding| replace::
82+
The encoding for directories and filenames (default: ``'utf-8'``).
83+
8184
.. class:: FTP(host='', user='', passwd='', acct='', timeout=None, \
8285
source_address=None, *, encoding='utf-8')
8386
@@ -108,8 +111,7 @@ FTP objects
108111
:type source_address: tuple | None
109112

110113
:param str encoding:
111-
The *encoding* parameter specifies the encoding
112-
for directories and filenames.
114+
|param_doc_encoding|
113115

114116
The :class:`FTP` class supports the :keyword:`with` statement, e.g.:
115117

@@ -447,19 +449,53 @@ FTP_TLS objects
447449
.. class:: FTP_TLS(host='', user='', passwd='', acct='', *, context=None, \
448450
timeout=None, source_address=None, encoding='utf-8')
449451

450-
A :class:`FTP` subclass which adds TLS support to FTP as described in
452+
An :class:`FTP` subclass which adds TLS support to FTP as described in
451453
:rfc:`4217`.
452-
Connect as usual to port 21 implicitly securing the FTP control connection
453-
before authenticating. Securing the data connection requires the user to
454-
explicitly ask for it by calling the :meth:`prot_p` method. *context*
455-
is a :class:`ssl.SSLContext` object which allows bundling SSL configuration
456-
options, certificates and private keys into a single (potentially
457-
long-lived) structure. Please read :ref:`ssl-security` for best practices.
454+
Connect to port 21 implicitly securing the FTP control connection
455+
before authenticating.
456+
457+
.. note::
458+
The user must explicitly secure the data connection
459+
by calling the :meth:`prot_p` method.
460+
461+
:param str host:
462+
The hostname to connect to.
463+
If given, :code:`connect(host)` is implicitly called by the constructor.
464+
465+
:param str user:
466+
|param_doc_user|
467+
If given, :code:`login(host, passwd, acct)` is implicitly called
468+
by the constructor.
469+
470+
:param str passwd:
471+
|param_doc_passwd|
472+
473+
:param str acct:
474+
|param_doc_acct|
475+
476+
:param context:
477+
An SSL context object which allows bundling SSL configuration options,
478+
certificates and private keys into a single, potentially long-lived,
479+
structure.
480+
Please read :ref:`ssl-security` for best practices.
481+
:type context: :class:`ssl.SSLContext`
482+
483+
:param timeout:
484+
A timeout in seconds for blocking operations like :meth:`~FTP.connect`
485+
(default: the global default timeout setting).
486+
:type timeout: int | None
487+
488+
:param source_address:
489+
|param_doc_source_address|
490+
:type source_address: tuple | None
491+
492+
:param str encoding:
493+
|param_doc_encoding|
458494

459495
.. versionadded:: 3.2
460496

461497
.. versionchanged:: 3.3
462-
*source_address* parameter was added.
498+
Added the *source_address* parameter.
463499

464500
.. versionchanged:: 3.4
465501
The class now supports hostname check with

Doc/library/glob.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ The :mod:`glob` module defines the following functions:
147147

148148
.. seealso::
149149

150-
:meth:`pathlib.PurePath.match` and :meth:`pathlib.Path.glob` methods,
151-
which call this function to implement pattern matching and globbing.
150+
:meth:`pathlib.PurePath.full_match` and :meth:`pathlib.Path.glob`
151+
methods, which call this function to implement pattern matching and
152+
globbing.
152153

153154
.. versionadded:: 3.13
154155

Doc/library/pathlib.rst

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -559,55 +559,55 @@ Pure paths provide the following methods and properties:
559559
PureWindowsPath('c:/Program Files')
560560

561561

562-
.. method:: PurePath.match(pattern, *, case_sensitive=None)
562+
.. method:: PurePath.full_match(pattern, *, case_sensitive=None)
563563

564564
Match this path against the provided glob-style pattern. Return ``True``
565-
if matching is successful, ``False`` otherwise.
566-
567-
If *pattern* is relative, the path can be either relative or absolute,
568-
and matching is done from the right::
565+
if matching is successful, ``False`` otherwise. For example::
569566

570-
>>> PurePath('a/b.py').match('*.py')
571-
True
572-
>>> PurePath('/a/b/c.py').match('b/*.py')
567+
>>> PurePath('a/b.py').full_match('a/*.py')
573568
True
574-
>>> PurePath('/a/b/c.py').match('a/*.py')
569+
>>> PurePath('a/b.py').full_match('*.py')
575570
False
571+
>>> PurePath('/a/b/c.py').full_match('/a/**')
572+
True
573+
>>> PurePath('/a/b/c.py').full_match('**/*.py')
574+
True
576575

577-
If *pattern* is absolute, the path must be absolute, and the whole path
578-
must match::
576+
As with other methods, case-sensitivity follows platform defaults::
579577

580-
>>> PurePath('/a.py').match('/*.py')
581-
True
582-
>>> PurePath('a/b.py').match('/*.py')
578+
>>> PurePosixPath('b.py').full_match('*.PY')
583579
False
580+
>>> PureWindowsPath('b.py').full_match('*.PY')
581+
True
584582

585-
The *pattern* may be another path object; this speeds up matching the same
586-
pattern against multiple files::
583+
Set *case_sensitive* to ``True`` or ``False`` to override this behaviour.
587584

588-
>>> pattern = PurePath('*.py')
589-
>>> PurePath('a/b.py').match(pattern)
590-
True
585+
.. versionadded:: 3.13
591586

592-
.. versionchanged:: 3.12
593-
Accepts an object implementing the :class:`os.PathLike` interface.
594587

595-
As with other methods, case-sensitivity follows platform defaults::
588+
.. method:: PurePath.match(pattern, *, case_sensitive=None)
596589

597-
>>> PurePosixPath('b.py').match('*.PY')
598-
False
599-
>>> PureWindowsPath('b.py').match('*.PY')
590+
Match this path against the provided non-recursive glob-style pattern.
591+
Return ``True`` if matching is successful, ``False`` otherwise.
592+
593+
This method is similar to :meth:`~PurePath.full_match`, but empty patterns
594+
aren't allowed (:exc:`ValueError` is raised), the recursive wildcard
595+
"``**``" isn't supported (it acts like non-recursive "``*``"), and if a
596+
relative pattern is provided, then matching is done from the right::
597+
598+
>>> PurePath('a/b.py').match('*.py')
599+
True
600+
>>> PurePath('/a/b/c.py').match('b/*.py')
600601
True
602+
>>> PurePath('/a/b/c.py').match('a/*.py')
603+
False
601604

602-
Set *case_sensitive* to ``True`` or ``False`` to override this behaviour.
605+
.. versionchanged:: 3.12
606+
The *pattern* parameter accepts a :term:`path-like object`.
603607

604608
.. versionchanged:: 3.12
605609
The *case_sensitive* parameter was added.
606610

607-
.. versionchanged:: 3.13
608-
Support for the recursive wildcard "``**``" was added. In previous
609-
versions, it acted like the non-recursive wildcard "``*``".
610-
611611

612612
.. method:: PurePath.relative_to(other, walk_up=False)
613613

Doc/library/ssl.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,12 +2574,8 @@ provided.
25742574
:exc:`SSLWantReadError` if it needs more data than the incoming BIO has
25752575
available.
25762576

2577-
- There is no module-level ``wrap_bio()`` call like there is for
2578-
:meth:`~SSLContext.wrap_socket`. An :class:`SSLObject` is always created
2579-
via an :class:`SSLContext`.
2580-
25812577
.. versionchanged:: 3.7
2582-
:class:`SSLObject` instances must to created with
2578+
:class:`SSLObject` instances must be created with
25832579
:meth:`~SSLContext.wrap_bio`. In earlier versions, it was possible to
25842580
create instances directly. This was never documented or officially
25852581
supported.

Doc/library/sys.monitoring.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ following IDs are pre-defined to make co-operation of tools easier::
7575
sys.monitoring.PROFILER_ID = 2
7676
sys.monitoring.OPTIMIZER_ID = 5
7777

78-
There is no obligation to set an ID, nor is there anything preventing a tool
79-
from using an ID even it is already in use.
80-
However, tools are encouraged to use a unique ID and respect other tools.
8178

8279
Events
8380
------

Doc/library/threading.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,10 @@ All methods are executed atomically.
534534
lock, subsequent attempts to acquire it block, until it is released; any
535535
thread may release it.
536536

537-
Note that ``Lock`` is actually a factory function which returns an instance
538-
of the most efficient version of the concrete Lock class that is supported
539-
by the platform.
537+
.. versionchanged:: 3.13
538+
``Lock`` is now a class. In earlier Pythons, ``Lock`` was a factory
539+
function which returned an instance of the underlying private lock
540+
type.
540541

541542

542543
.. method:: acquire(blocking=True, timeout=-1)

Doc/library/types.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ Standard names are defined for the following types:
398398
data members which use standard conversion functions; it has the same purpose
399399
as the :class:`property` type, but for classes defined in extension modules.
400400

401+
In addition, when a class is defined with a :attr:`~object.__slots__` attribute, then for
402+
each slot, an instance of :class:`!MemberDescriptorType` will be added as an attribute
403+
on the class. This allows the slot to appear in the class's :attr:`~object.__dict__`.
404+
401405
.. impl-detail::
402406

403407
In other implementations of Python, this type may be identical to

Doc/tools/.nitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Doc/c-api/memoryview.rst
1414
Doc/c-api/module.rst
1515
Doc/c-api/object.rst
1616
Doc/c-api/stable.rst
17-
Doc/c-api/structures.rst
1817
Doc/c-api/sys.rst
1918
Doc/c-api/type.rst
2019
Doc/c-api/typeobj.rst
@@ -29,7 +28,6 @@ Doc/library/asyncio-policy.rst
2928
Doc/library/asyncio-subprocess.rst
3029
Doc/library/bdb.rst
3130
Doc/library/collections.rst
32-
Doc/library/concurrent.futures.rst
3331
Doc/library/csv.rst
3432
Doc/library/datetime.rst
3533
Doc/library/dbm.rst

Doc/whatsnew/3.13.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ pathlib
336336
object from a 'file' URI (``file:/``).
337337
(Contributed by Barney Gale in :gh:`107465`.)
338338

339-
* Add support for recursive wildcards in :meth:`pathlib.PurePath.match`.
339+
* Add :meth:`pathlib.PurePath.full_match` for matching paths with
340+
shell-style wildcards, including the recursive wildcard "``**``".
340341
(Contributed by Barney Gale in :gh:`73435`.)
341342

342343
* Add *follow_symlinks* keyword-only argument to :meth:`pathlib.Path.glob`,

0 commit comments

Comments
 (0)