Skip to content

Commit cffe844

Browse files
authored
Merge branch 'main' into code_hash
2 parents 2014fb1 + f3db68e commit cffe844

File tree

84 files changed

+1190
-864
lines changed

Some content is hidden

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

84 files changed

+1190
-864
lines changed

.github/workflows/doc.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,8 @@ jobs:
5050
run: make -C Doc/ venv
5151
- name: 'Check documentation'
5252
run: make -C Doc/ check
53-
- name: 'Upload NEWS'
54-
uses: actions/upload-artifact@v3
55-
with:
56-
name: NEWS
57-
path: Doc/build/NEWS
5853
- name: 'Build HTML documentation'
5954
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html
60-
- name: 'Upload docs'
61-
uses: actions/upload-artifact@v3
62-
with:
63-
name: doc-html
64-
path: Doc/build/html
6555

6656
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
6757
doctest:

Doc/c-api/apiabiversion.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ 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+
Use this for numeric comparisons, e.g. ``#if PY_VERSION_HEX >= ...``.
62+
6163
This version is also available via the symbol :data:`Py_Version`.
6264

6365
.. c:var:: const unsigned long Py_Version

Doc/c-api/structures.rst

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -228,29 +228,30 @@ Implementing functions and methods
228228
Structure used to describe a method of an extension type. This structure has
229229
four fields:
230230
231-
+------------------+---------------+-------------------------------+
232-
| Field | C Type | Meaning |
233-
+==================+===============+===============================+
234-
| :attr:`ml_name` | const char \* | name of the method |
235-
+------------------+---------------+-------------------------------+
236-
| :attr:`ml_meth` | PyCFunction | pointer to the C |
237-
| | | implementation |
238-
+------------------+---------------+-------------------------------+
239-
| :attr:`ml_flags` | int | flag bits indicating how the |
240-
| | | call should be constructed |
241-
+------------------+---------------+-------------------------------+
242-
| :attr:`ml_doc` | const char \* | points to the contents of the |
243-
| | | docstring |
244-
+------------------+---------------+-------------------------------+
245-
246-
The :attr:`ml_meth` is a C function pointer. The functions may be of different
231+
.. c:member:: const char* ml_name
232+
233+
name of the method
234+
235+
.. c:member:: PyCFunction ml_meth
236+
237+
pointer to the C implementation
238+
239+
.. c:member:: int ml_flags
240+
241+
flags bits indicating how the call should be constructed
242+
243+
.. c:member:: const char* ml_doc
244+
245+
points to the contents of the docstring
246+
247+
The :c:member:`ml_meth` is a C function pointer. The functions may be of different
247248
types, but they always return :c:expr:`PyObject*`. If the function is not of
248249
the :c:type:`PyCFunction`, the compiler will require a cast in the method table.
249250
Even though :c:type:`PyCFunction` defines the first parameter as
250251
:c:expr:`PyObject*`, it is common that the method implementation uses the
251252
specific C type of the *self* object.
252253
253-
The :attr:`ml_flags` field is a bitfield which can include the following flags.
254+
The :c:member:`ml_flags` field is a bitfield which can include the following flags.
254255
The individual flags indicate either a calling convention or a binding
255256
convention.
256257

Doc/faq/programming.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ Yes. The coding style required for standard library modules is documented as
113113
Core Language
114114
=============
115115

116+
.. _faq-unboundlocalerror:
117+
116118
Why am I getting an UnboundLocalError when the variable has a value?
117119
--------------------------------------------------------------------
118120

Doc/library/contextvars.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ Manual Context Management
144144
To get a copy of the current context use the
145145
:func:`~contextvars.copy_context` function.
146146

147+
Every thread will have a different top-level :class:`~contextvars.Context`
148+
object. This means that a :class:`ContextVar` object behaves in a similar
149+
fashion to :func:`threading.local()` when values are assigned in different
150+
threads.
151+
147152
Context implements the :class:`collections.abc.Mapping` interface.
148153

149154
.. method:: run(callable, *args, **kwargs)

Doc/library/imaplib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ IMAP4 Objects
187187
-------------
188188

189189
All IMAP4rev1 commands are represented by methods of the same name, either
190-
upper-case or lower-case.
190+
uppercase or lowercase.
191191

192192
All arguments to commands are converted to strings, except for ``AUTHENTICATE``,
193193
and the last argument to ``APPEND`` which is passed as an IMAP4 literal. If

Doc/library/inspect.rst

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,36 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
343343

344344
.. function:: iscoroutinefunction(object)
345345

346-
Return ``True`` if the object is a :term:`coroutine function`
347-
(a function defined with an :keyword:`async def` syntax).
346+
Return ``True`` if the object is a :term:`coroutine function` (a function
347+
defined with an :keyword:`async def` syntax), a :func:`functools.partial`
348+
wrapping a :term:`coroutine function`, or a sync function marked with
349+
:func:`markcoroutinefunction`.
348350

349351
.. versionadded:: 3.5
350352

351353
.. versionchanged:: 3.8
352354
Functions wrapped in :func:`functools.partial` now return ``True`` if the
353355
wrapped function is a :term:`coroutine function`.
354356

357+
.. versionchanged:: 3.12
358+
Sync functions marked with :func:`markcoroutinefunction` now return
359+
``True``.
360+
361+
362+
.. function:: markcoroutinefunction(func)
363+
364+
Decorator to mark a callable as a :term:`coroutine function` if it would not
365+
otherwise be detected by :func:`iscoroutinefunction`.
366+
367+
This may be of use for sync functions that return a :term:`coroutine`, if
368+
the function is passed to an API that requires :func:`iscoroutinefunction`.
369+
370+
When possible, using an :keyword:`async def` function is preferred. Also
371+
acceptable is calling the function and testing the return with
372+
:func:`iscoroutine`.
373+
374+
.. versionadded:: 3.12
375+
355376

356377
.. function:: iscoroutine(object)
357378

Doc/library/re.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,9 @@ character ``'$'``.
591591

592592
``\w``
593593
For Unicode (str) patterns:
594-
Matches Unicode word characters; this includes most characters
595-
that can be part of a word in any language, as well as numbers and
596-
the underscore. If the :const:`ASCII` flag is used, only
597-
``[a-zA-Z0-9_]`` is matched.
594+
Matches Unicode word characters; this includes alphanumeric characters (as defined by :meth:`str.isalnum`)
595+
as well as the underscore (``_``).
596+
If the :const:`ASCII` flag is used, only ``[a-zA-Z0-9_]`` is matched.
598597

599598
For 8-bit (bytes) patterns:
600599
Matches characters considered alphanumeric in the ASCII character set;

Doc/library/ssl.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,13 @@ Constants
823823

824824
.. versionadded:: 3.12
825825

826+
.. data:: OP_LEGACY_SERVER_CONNECT
827+
828+
Allow legacy insecure renegotiation between OpenSSL and unpatched servers
829+
only.
830+
831+
.. versionadded:: 3.12
832+
826833
.. data:: HAS_ALPN
827834

828835
Whether the OpenSSL library has built-in support for the *Application-Layer

Doc/library/stdtypes.rst

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,25 +1624,28 @@ expression support in the :mod:`re` module).
16241624

16251625
.. method:: str.encode(encoding="utf-8", errors="strict")
16261626

1627-
Return an encoded version of the string as a bytes object. Default encoding
1628-
is ``'utf-8'``. *errors* may be given to set a different error handling scheme.
1629-
The default for *errors* is ``'strict'``, meaning that encoding errors raise
1630-
a :exc:`UnicodeError`. Other possible
1631-
values are ``'ignore'``, ``'replace'``, ``'xmlcharrefreplace'``,
1632-
``'backslashreplace'`` and any other name registered via
1633-
:func:`codecs.register_error`, see section :ref:`error-handlers`. For a
1634-
list of possible encodings, see section :ref:`standard-encodings`.
1635-
1636-
By default, the *errors* argument is not checked for best performances, but
1637-
only used at the first encoding error. Enable the :ref:`Python Development
1638-
Mode <devmode>`, or use a :ref:`debug build <debug-build>` to check
1639-
*errors*.
1627+
Return the string encoded to :class:`bytes`.
1628+
1629+
*encoding* defaults to ``'utf-8'``;
1630+
see :ref:`standard-encodings` for possible values.
1631+
1632+
*errors* controls how encoding errors are handled.
1633+
If ``'strict'`` (the default), a :exc:`UnicodeError` exception is raised.
1634+
Other possible values are ``'ignore'``,
1635+
``'replace'``, ``'xmlcharrefreplace'``, ``'backslashreplace'`` and any
1636+
other name registered via :func:`codecs.register_error`.
1637+
See :ref:`error-handlers` for details.
1638+
1639+
For performance reasons, the value of *errors* is not checked for validity
1640+
unless an encoding error actually occurs,
1641+
:ref:`devmode` is enabled
1642+
or a :ref:`debug build <debug-build>` is used.
16401643

16411644
.. versionchanged:: 3.1
1642-
Support for keyword arguments added.
1645+
Added support for keyword arguments.
16431646

16441647
.. versionchanged:: 3.9
1645-
The *errors* is now checked in development mode and
1648+
The value of the *errors* argument is now checked in :ref:`devmode` and
16461649
in :ref:`debug mode <debug-build>`.
16471650

16481651

@@ -2759,29 +2762,32 @@ arbitrary binary data.
27592762
.. method:: bytes.decode(encoding="utf-8", errors="strict")
27602763
bytearray.decode(encoding="utf-8", errors="strict")
27612764

2762-
Return a string decoded from the given bytes. Default encoding is
2763-
``'utf-8'``. *errors* may be given to set a different
2764-
error handling scheme. The default for *errors* is ``'strict'``, meaning
2765-
that encoding errors raise a :exc:`UnicodeError`. Other possible values are
2766-
``'ignore'``, ``'replace'`` and any other name registered via
2767-
:func:`codecs.register_error`, see section :ref:`error-handlers`. For a
2768-
list of possible encodings, see section :ref:`standard-encodings`.
2765+
Return the bytes decoded to a :class:`str`.
2766+
2767+
*encoding* defaults to ``'utf-8'``;
2768+
see :ref:`standard-encodings` for possible values.
2769+
2770+
*errors* controls how decoding errors are handled.
2771+
If ``'strict'`` (the default), a :exc:`UnicodeError` exception is raised.
2772+
Other possible values are ``'ignore'``, ``'replace'``,
2773+
and any other name registered via :func:`codecs.register_error`.
2774+
See :ref:`error-handlers` for details.
27692775

2770-
By default, the *errors* argument is not checked for best performances, but
2771-
only used at the first decoding error. Enable the :ref:`Python Development
2772-
Mode <devmode>`, or use a :ref:`debug build <debug-build>` to check *errors*.
2776+
For performance reasons, the value of *errors* is not checked for validity
2777+
unless a decoding error actually occurs,
2778+
:ref:`devmode` is enabled or a :ref:`debug build <debug-build>` is used.
27732779

27742780
.. note::
27752781

27762782
Passing the *encoding* argument to :class:`str` allows decoding any
27772783
:term:`bytes-like object` directly, without needing to make a temporary
2778-
bytes or bytearray object.
2784+
:class:`!bytes` or :class:`!bytearray` object.
27792785

27802786
.. versionchanged:: 3.1
27812787
Added support for keyword arguments.
27822788

27832789
.. versionchanged:: 3.9
2784-
The *errors* is now checked in development mode and
2790+
The value of the *errors* argument is now checked in :ref:`devmode` and
27852791
in :ref:`debug mode <debug-build>`.
27862792

27872793

@@ -5480,7 +5486,7 @@ to mitigate denial of service attacks. This limit *only* applies to decimal or
54805486
other non-power-of-two number bases. Hexadecimal, octal, and binary conversions
54815487
are unlimited. The limit can be configured.
54825488

5483-
The :class:`int` type in CPython is an abitrary length number stored in binary
5489+
The :class:`int` type in CPython is an arbitrary length number stored in binary
54845490
form (commonly known as a "bignum"). There exists no algorithm that can convert
54855491
a string to a binary integer or a binary integer to a string in linear time,
54865492
*unless* the base is a power of 2. Even the best known algorithms for base 10
@@ -5544,7 +5550,7 @@ and :class:`str` or :class:`bytes`:
55445550
* ``int(string)`` with default base 10.
55455551
* ``int(string, base)`` for all bases that are not a power of 2.
55465552
* ``str(integer)``.
5547-
* ``repr(integer)``
5553+
* ``repr(integer)``.
55485554
* any other string conversion to base 10, for example ``f"{integer}"``,
55495555
``"{}".format(integer)``, or ``b"%d" % integer``.
55505556

@@ -5572,7 +5578,7 @@ command line flag to configure the limit:
55725578
:envvar:`PYTHONINTMAXSTRDIGITS` or :option:`-X int_max_str_digits <-X>`.
55735579
If both the env var and the ``-X`` option are set, the ``-X`` option takes
55745580
precedence. A value of *-1* indicates that both were unset, thus a value of
5575-
:data:`sys.int_info.default_max_str_digits` was used during initilization.
5581+
:data:`sys.int_info.default_max_str_digits` was used during initialization.
55765582

55775583
From code, you can inspect the current limit and set a new one using these
55785584
:mod:`sys` APIs:

0 commit comments

Comments
 (0)