Skip to content

Commit a5cf326

Browse files
Merge branch 'main' into doc-unicode-compact
2 parents 03589fc + 1932127 commit a5cf326

File tree

120 files changed

+3410
-1846
lines changed

Some content is hidden

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

120 files changed

+3410
-1846
lines changed

Doc/c-api/apiabiversion.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ See :ref:`stable` for a discussion of API and ABI stability across versions.
3434
This can be ``0xA`` for alpha, ``0xB`` for beta, ``0xC`` for release
3535
candidate or ``0xF`` for final.
3636

37+
38+
.. c:namespace:: NULL
39+
.. c:macro:: PY_RELEASE_LEVEL_ALPHA
40+
:no-typesetting:
41+
.. c:macro:: PY_RELEASE_LEVEL_BETA
42+
:no-typesetting:
43+
.. c:macro:: PY_RELEASE_LEVEL_GAMMA
44+
:no-typesetting:
45+
.. c:macro:: PY_RELEASE_LEVEL_FINAL
46+
:no-typesetting:
47+
48+
For completeness, the values are available as macros:
49+
:c:macro:`!PY_RELEASE_LEVEL_ALPHA` (``0xA``),
50+
:c:macro:`!PY_RELEASE_LEVEL_BETA` (``0xB``),
51+
:c:macro:`!PY_RELEASE_LEVEL_GAMMA` (``0xC``), and
52+
:c:macro:`!PY_RELEASE_LEVEL_FINAL` (``0xF``).
53+
3754
.. c:macro:: PY_RELEASE_SERIAL
3855
3956
The ``2`` in ``3.4.1a2``. Zero for final releases.
@@ -46,6 +63,10 @@ See :ref:`stable` for a discussion of API and ABI stability across versions.
4663
Use this for numeric comparisons, for example,
4764
``#if PY_VERSION_HEX >= ...``.
4865

66+
.. c:macro:: PY_VERSION
67+
68+
The Python version as a string, for example, ``"3.4.1a2"``.
69+
4970

5071
Run-time version
5172
----------------

Doc/c-api/module.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,15 +820,18 @@ struct:
820820
.. versionadded:: 3.5
821821
822822
.. c:macro:: PYTHON_API_VERSION
823+
PYTHON_API_STRING
823824
824-
The C API version. Defined for backwards compatibility.
825+
The C API version, as an integer (``1013``) and string (``"1013"``), respectively.
826+
Defined for backwards compatibility.
825827
826828
Currently, this constant is not updated in new Python versions, and is not
827829
useful for versioning. This may change in the future.
828830
829831
.. c:macro:: PYTHON_ABI_VERSION
832+
PYTHON_ABI_STRING
830833
831-
Defined as ``3`` for backwards compatibility.
834+
Defined as ``3`` and ``"3"``, respectively, for backwards compatibility.
832835
833836
Currently, this constant is not updated in new Python versions, and is not
834837
useful for versioning. This may change in the future.

Doc/library/concurrent.futures.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ or separate processes, using :class:`ProcessPoolExecutor`.
2121
Each implements the same interface, which is defined
2222
by the abstract :class:`Executor` class.
2323

24+
:class:`concurrent.futures.Future` must not be confused with
25+
:class:`asyncio.Future`, which is designed for use with :mod:`asyncio`
26+
tasks and coroutines. See the :doc:`asyncio's Future <asyncio-future>`
27+
documentation for a detailed comparison of the two.
28+
2429
.. include:: ../includes/wasm-notavail.rst
2530

2631
Executor Objects

Doc/library/dis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ not have to be) the original ``STACK[-2]``.
768768
end = STACK.pop()
769769
start = STACK.pop()
770770
container = STACK.pop()
771-
values = STACK.pop()
771+
value = STACK.pop()
772772
container[start:end] = value
773773

774774
.. versionadded:: 3.12

Doc/library/email.message.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ message objects.
5757
:class:`~email.policy.default` policy, which follows the rules of the email
5858
RFCs except for line endings (instead of the RFC mandated ``\r\n``, it uses
5959
the Python standard ``\n`` line endings). For more information see the
60-
:mod:`~email.policy` documentation.
60+
:mod:`~email.policy` documentation. [2]_
6161

6262
.. method:: as_string(unixfrom=False, maxheaderlen=None, policy=None)
6363

@@ -749,3 +749,9 @@ message objects.
749749
.. [1] Originally added in 3.4 as a :term:`provisional module <provisional
750750
package>`. Docs for legacy message class moved to
751751
:ref:`compat32_message`.
752+
753+
.. [2] The :class:`EmailMessage` class requires a policy that provides a
754+
``content_manager`` attribute for content management methods like
755+
``set_content()`` and ``get_content()`` to work. The legacy
756+
:const:`~email.policy.compat32` policy does not support these methods
757+
and should not be used with :class:`EmailMessage`.

Doc/library/email.policy.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,13 @@ The header objects and their attributes are described in
662662
An instance of :class:`Compat32`, providing backward compatibility with the
663663
behavior of the email package in Python 3.2.
664664

665+
.. note::
666+
667+
The :const:`compat32` policy should not be used as a policy for
668+
:class:`~email.message.EmailMessage` objects, and should only be used
669+
to serialize messages that were created using the :const:`compat32`
670+
policy.
671+
665672

666673
.. rubric:: Footnotes
667674

Doc/library/ftplib.rst

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,9 @@ FTP_TLS objects
524524
:class:`!FTP_TLS` class inherits from :class:`FTP`,
525525
defining these additional methods and attributes:
526526

527-
.. attribute:: FTP_TLS.ssl_version
528-
529-
The SSL version to use (defaults to :data:`ssl.PROTOCOL_SSLv23`).
530-
531527
.. method:: FTP_TLS.auth()
532528

533-
Set up a secure control connection by using TLS or SSL, depending on what
534-
is specified in the :attr:`ssl_version` attribute.
529+
Set up a secure control connection by using TLS.
535530

536531
.. versionchanged:: 3.4
537532
The method now supports hostname check with
@@ -548,7 +543,7 @@ FTP_TLS objects
548543

549544
.. method:: FTP_TLS.prot_p()
550545

551-
Set up secure data connection.
546+
Set up secure data connection by using TLS.
552547

553548
.. method:: FTP_TLS.prot_c()
554549

Doc/library/importlib.resources.abc.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@
6363
If the resource does not concretely exist on the file system,
6464
raise :exc:`FileNotFoundError`.
6565

66-
.. method:: is_resource(name)
66+
.. method:: is_resource(path)
6767
:abstractmethod:
6868

69-
Returns ``True`` if the named *name* is considered a resource.
70-
:exc:`FileNotFoundError` is raised if *name* does not exist.
69+
Returns ``True`` if the named *path* is considered a resource.
70+
:exc:`FileNotFoundError` is raised if *path* does not exist.
71+
72+
.. versionchanged:: 3.10
73+
The argument *name* was renamed to *path*.
7174

7275
.. method:: contents()
7376
:abstractmethod:

Doc/library/importlib.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,6 @@ Functions
210210
:exc:`ModuleNotFoundError` is raised when the module being reloaded lacks
211211
a :class:`~importlib.machinery.ModuleSpec`.
212212

213-
.. versionchanged:: 3.15
214-
If *module* is a lazy module that has not yet been materialized (i.e.,
215-
loaded via :class:`importlib.util.LazyLoader` and not yet accessed),
216-
calling :func:`reload` is a no-op and returns the module unchanged.
217-
This prevents the reload from unintentionally triggering the lazy load.
218-
219213
.. warning::
220214
This function is not thread-safe. Calling it from multiple threads can result
221215
in unexpected behavior. It's recommended to use the :class:`threading.Lock`

Doc/library/stdtypes.rst

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,14 @@ expression support in the :mod:`re` module).
18441844
lowercase letter ``'ß'`` is equivalent to ``"ss"``. Since it is already
18451845
lowercase, :meth:`lower` would do nothing to ``'ß'``; :meth:`casefold`
18461846
converts it to ``"ss"``.
1847+
For example:
1848+
1849+
.. doctest::
1850+
1851+
>>> 'straße'.lower()
1852+
'straße'
1853+
>>> 'straße'.casefold()
1854+
'strasse'
18471855

18481856
The casefolding algorithm is `described in section 3.13.3 'Default Case
18491857
Folding' of the Unicode Standard
@@ -2045,7 +2053,18 @@ expression support in the :mod:`re` module).
20452053
.. method:: str.index(sub[, start[, end]])
20462054

20472055
Like :meth:`~str.find`, but raise :exc:`ValueError` when the substring is
2048-
not found.
2056+
not found. For example:
2057+
2058+
.. doctest::
2059+
2060+
>>> 'spam, spam, spam'.index('eggs')
2061+
Traceback (most recent call last):
2062+
File "<python-input-0>", line 1, in <module>
2063+
'spam, spam, spam'.index('eggs')
2064+
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
2065+
ValueError: substring not found
2066+
2067+
See also :meth:`rindex`.
20492068

20502069

20512070
.. method:: str.isalnum()
@@ -2289,7 +2308,12 @@ expression support in the :mod:`re` module).
22892308
.. method:: str.lower()
22902309

22912310
Return a copy of the string with all the cased characters [4]_ converted to
2292-
lowercase.
2311+
lowercase. For example:
2312+
2313+
.. doctest::
2314+
2315+
>>> 'Lower Method Example'.lower()
2316+
'lower method example'
22932317

22942318
The lowercasing algorithm used is `described in section 3.13.2 'Default Case
22952319
Conversion' of the Unicode Standard
@@ -2345,7 +2369,9 @@ expression support in the :mod:`re` module).
23452369

23462370
If the string starts with the *prefix* string, return
23472371
``string[len(prefix):]``. Otherwise, return a copy of the original
2348-
string::
2372+
string:
2373+
2374+
.. doctest::
23492375

23502376
>>> 'TestHook'.removeprefix('Test')
23512377
'Hook'
@@ -2354,12 +2380,16 @@ expression support in the :mod:`re` module).
23542380

23552381
.. versionadded:: 3.9
23562382

2383+
See also :meth:`removesuffix` and :meth:`startswith`.
2384+
23572385

23582386
.. method:: str.removesuffix(suffix, /)
23592387

23602388
If the string ends with the *suffix* string and that *suffix* is not empty,
23612389
return ``string[:-len(suffix)]``. Otherwise, return a copy of the
2362-
original string::
2390+
original string:
2391+
2392+
.. doctest::
23632393

23642394
>>> 'MiscTests'.removesuffix('Tests')
23652395
'Misc'
@@ -2368,12 +2398,22 @@ expression support in the :mod:`re` module).
23682398

23692399
.. versionadded:: 3.9
23702400

2401+
See also :meth:`removeprefix` and :meth:`endswith`.
2402+
23712403

23722404
.. method:: str.replace(old, new, /, count=-1)
23732405

23742406
Return a copy of the string with all occurrences of substring *old* replaced by
23752407
*new*. If *count* is given, only the first *count* occurrences are replaced.
23762408
If *count* is not specified or ``-1``, then all occurrences are replaced.
2409+
For example:
2410+
2411+
.. doctest::
2412+
2413+
>>> 'spam, spam, spam'.replace('spam', 'eggs')
2414+
'eggs, eggs, eggs'
2415+
>>> 'spam, spam, spam'.replace('spam', 'eggs', 1)
2416+
'eggs, spam, spam'
23772417

23782418
.. versionchanged:: 3.13
23792419
*count* is now supported as a keyword argument.
@@ -2384,6 +2424,16 @@ expression support in the :mod:`re` module).
23842424
Return the highest index in the string where substring *sub* is found, such
23852425
that *sub* is contained within ``s[start:end]``. Optional arguments *start*
23862426
and *end* are interpreted as in slice notation. Return ``-1`` on failure.
2427+
For example:
2428+
2429+
.. doctest::
2430+
2431+
>>> 'spam, spam, spam'.rfind('sp')
2432+
12
2433+
>>> 'spam, spam, spam'.rfind('sp', 0, 10)
2434+
6
2435+
2436+
See also :meth:`find` and :meth:`rindex`.
23872437

23882438

23892439
.. method:: str.rindex(sub[, start[, end]])

0 commit comments

Comments
 (0)