Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ab383eb
bpo-44114: Fix dictkeys_reversed and dictvalues_reversed function sig…
joemarshall May 13, 2021
d1560d2
bpo-43757: Document os.path.realpath(strict=True) in 3.10 whatsnew. (…
barneygale May 13, 2021
366c69f
bpo-39906: Document new follow_symlinks argument to pathlib.Path.stat…
barneygale May 13, 2021
3c0b070
Fix typo in configure (GH-26078)
eltociear May 13, 2021
1aa3530
bpo-44125: Fix "make patchcheck" on non-English locale (GH-26102)
pitrou May 13, 2021
e0c614e
bpo-44114: Remove redundant cast. (GH-26098)
methane May 13, 2021
ae3c66a
bpo-44094: Remove deprecated PyErr_ APIs. (GH-26011)
methane May 13, 2021
4aeee0b
bpo-28146: Fix a confusing error message in str.format() (GH-24213)
iritkatriel May 13, 2021
a09fc9c
bpo-43908: Add What's New entry for Py_TPFLAGS_IMMUTABLETYPE flag (GH…
May 13, 2021
ddd30b2
Reword paragraph on specific value for Py_LIMITED_API (GH-26101)
encukou May 14, 2021
53c91ac
bpo-43977: Update pattern matching language reference docs (GH-25917)
Fidget-Spinner May 14, 2021
3d4b5f1
Update doc as relative import can be used with star import (GH-25667)
gousaiyang May 14, 2021
65d180d
bpo-38250: add version added for FlagBoundary (GH-25820)
hauntsaninja May 14, 2021
56b8ea6
Updated code example for asyncio.gather (GH-20604)
josephernest May 14, 2021
fe175a8
Doc: Fix ambiguous pronoun (GH-26037)
danielshahaf May 14, 2021
be7e467
sqlite3 test suite now works with SQLITE_DQS=0 (GH-26032)
May 14, 2021
19d839a
[doc] Fix typos in cgi.rst (#24766)
geryogam May 14, 2021
2918846
Subprocess Protocols Documentation (GH-20950)
kudavid May 14, 2021
dc0b364
bpo-44095: Add suffix, stem and suffixes to zipfile.Path (GH-26129)
miguendes May 14, 2021
0779712
bpo-43729: Clarify comment in tutorial example (GH-25191)
May 14, 2021
c10c2ec
bpo-37788: Fix reference leak when Thread is never joined (GH-26103)
pitrou May 14, 2021
4aa63d6
bpo-44072: fix Complex, Integral docs for `**` (GH-25986)
roryyorke May 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Doc/c-api/stable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ embedding Python.)

.. c:macro:: Py_LIMITED_API

Define this macro ``Py_LIMITED_API`` before including ``Python.h`` to
opt in to only use the Limited API.

Defining ``Py_LIMITED_API`` to ``3`` will limit the available API so that
the extension will work without recompilation with all Python 3.x releases
(x>=2) on the particular :ref:`platform <stable-abi-platform>`.

Defining ``Py_LIMITED_API`` to a value of :c:data:`PY_VERSION_HEX` will
limit the available API so that the extension will work without
recompilation with all Python 3 releases from the specified one.
This will allow using additional API introduced up to this version,
but the extension will lose compatibility with earlier Python versions.
Define this macro before including ``Python.h`` to opt in to only use
the Limited API, and to select the Limited API version.

Define ``Py_LIMITED_API`` to the value of :c:data:`PY_VERSION_HEX`
corresponding to the lowest Python version your extension supports.
The extension will work without recompilation with all Python 3 releases
from the specified one onward, and can use Limited API introduced up to that
version.

Rather than using the ``PY_VERSION_HEX`` macro directly, hardcode a minimum
minor version (e.g. ``0x030A0000`` for Python 3.10) for stability when
compiling with future Python versions.

You can also define ``Py_LIMITED_API`` to ``3``. This works the same as
``0x03020000`` (Python 3.2, the version that introduced Limited API).

On Windows, extensions that use the Stable ABI should be linked against
``python3.dll`` rather than a version-specific library such as
``python39.dll``.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-protocol.rst
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ factories passed to the :meth:`loop.create_datagram_endpoint` method.
Subprocess Protocols
--------------------

Datagram Protocol instances should be constructed by protocol
Subprocess Protocol instances should be constructed by protocol
factories passed to the :meth:`loop.subprocess_exec` and
:meth:`loop.subprocess_shell` methods.

Expand Down
19 changes: 11 additions & 8 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,32 +358,35 @@ Running Tasks Concurrently
async def factorial(name, number):
f = 1
for i in range(2, number + 1):
print(f"Task {name}: Compute factorial({i})...")
print(f"Task {name}: Compute factorial({number}), currently i={i}...")
await asyncio.sleep(1)
f *= i
print(f"Task {name}: factorial({number}) = {f}")
return f

async def main():
# Schedule three calls *concurrently*:
await asyncio.gather(
L = await asyncio.gather(
factorial("A", 2),
factorial("B", 3),
factorial("C", 4),
)
print(L)

asyncio.run(main())

# Expected output:
#
# Task A: Compute factorial(2)...
# Task B: Compute factorial(2)...
# Task C: Compute factorial(2)...
# Task A: Compute factorial(2), currently i=2...
# Task B: Compute factorial(3), currently i=2...
# Task C: Compute factorial(4), currently i=2...
# Task A: factorial(2) = 2
# Task B: Compute factorial(3)...
# Task C: Compute factorial(3)...
# Task B: Compute factorial(3), currently i=3...
# Task C: Compute factorial(4), currently i=3...
# Task B: factorial(3) = 6
# Task C: Compute factorial(4)...
# Task C: Compute factorial(4), currently i=4...
# Task C: factorial(4) = 24
# [2, 6, 24]

.. note::
If *return_exceptions* is False, cancelling gather() after it
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/cgi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ algorithms implemented in this module in other circumstances.
.. function:: test()

Robust test CGI script, usable as main program. Writes minimal HTTP headers and
formats all information provided to the script in HTML form.
formats all information provided to the script in HTML format.


.. function:: print_environ()
Expand Down Expand Up @@ -346,8 +346,8 @@ Caring about security

.. index:: pair: CGI; security

There's one important rule: if you invoke an external program (via the
:func:`os.system` or :func:`os.popen` functions. or others with similar
There's one important rule: if you invoke an external program (via
:func:`os.system`, :func:`os.popen` or other functions with similar
functionality), make very sure you don't pass arbitrary strings received from
the client to the shell. This is a well-known security hole whereby clever
hackers anywhere on the Web can exploit a gullible CGI script to invoke
Expand Down Expand Up @@ -424,7 +424,7 @@ above on installing your CGI script carefully can save you a lot of time. If
you wonder whether you have understood the installation procedure correctly, try
installing a copy of this module file (:file:`cgi.py`) as a CGI script. When
invoked as a script, the file will dump its environment and the contents of the
form in HTML form. Give it the right mode etc, and send it a request. If it's
form in HTML format. Give it the right mode etc., and send it a request. If it's
installed in the standard :file:`cgi-bin` directory, it should be possible to
send it a request by entering a URL into your browser of the form:

Expand Down
5 changes: 5 additions & 0 deletions Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ Data Types
>>> KeepFlag(2**2 + 2**4)
KeepFlag.BLUE|0x10

.. versionadded:: 3.10 ``FlagBoundary``


Utilites and Decorators
-----------------------
Expand All @@ -598,6 +600,7 @@ Utilites and Decorators
also injects the members, and their aliases, into the the global namespace
they were defined in.

.. versionadded:: 3.10

.. decorator:: property

Expand All @@ -610,6 +613,8 @@ Utilites and Decorators
*Enum* class, and *Enum* subclasses can define members with the
names ``value`` and ``name``.

.. versionadded:: 3.10

.. decorator:: unique

A :keyword:`class` decorator specifically for enumerations. It searches an
Expand Down
9 changes: 5 additions & 4 deletions Doc/library/numbers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ The numeric tower
Subclasses of this type describe complex numbers and include the operations
that work on the built-in :class:`complex` type. These are: conversions to
:class:`complex` and :class:`bool`, :attr:`.real`, :attr:`.imag`, ``+``,
``-``, ``*``, ``/``, :func:`abs`, :meth:`conjugate`, ``==``, and ``!=``. All
except ``-`` and ``!=`` are abstract.
``-``, ``*``, ``/``, ``**``, :func:`abs`, :meth:`conjugate`, ``==``, and
``!=``. All except ``-`` and ``!=`` are abstract.

.. attribute:: real

Expand Down Expand Up @@ -76,8 +76,9 @@ The numeric tower

Subtypes :class:`Rational` and adds a conversion to :class:`int`. Provides
defaults for :func:`float`, :attr:`~Rational.numerator`, and
:attr:`~Rational.denominator`. Adds abstract methods for ``**`` and
bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``, ``~``.
:attr:`~Rational.denominator`. Adds abstract methods for :func:`pow` with
modulus and bit-string operations: ``<<``, ``>>``, ``&``, ``^``, ``|``,
``~``.


Notes for type implementors
Expand Down
21 changes: 21 additions & 0 deletions Doc/library/zipfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,27 @@ Path objects are traversable using the ``/`` operator or ``joinpath``.
Return ``True`` if the current context references a file or
directory in the zip file.

.. data:: Path.suffix

The file extension of the final component.

.. versionadded:: 3.11
Added :data:`Path.suffix` property.

.. data:: Path.stem

The final path component, without its suffix.

.. versionadded:: 3.11
Added :data:`Path.stem` property.

.. data:: Path.suffixes

A list of the path’s file extensions.

.. versionadded:: 3.11
Added :data:`Path.suffixes` property.

.. method:: Path.read_text(*, **)

Read the current file as unicode text. Positional and
Expand Down
44 changes: 36 additions & 8 deletions Doc/reference/compound_stmts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ is found that matches the exception. An expression-less except clause, if
present, must be last; it matches any exception. For an except clause with an
expression, that expression is evaluated, and the clause matches the exception
if the resulting object is "compatible" with the exception. An object is
compatible with an exception if it is the class or a base class of the exception
compatible with an exception if the object is the class or a base class of the exception
object, or a tuple containing an item that is the class or a base class of
the exception object.

Expand Down Expand Up @@ -822,7 +822,7 @@ and binds no name. Syntax:

``_`` is a :ref:`soft keyword <soft-keywords>` within any pattern,
but only within patterns. It is an identifier, as usual, even within
``match`` headers, ``guards``, and ``case`` blocks.
``match`` subject expressions, ``guard``\ s, and ``case`` blocks.

In simple terms, ``_`` will always succeed.

Expand Down Expand Up @@ -900,8 +900,8 @@ sequence pattern.
The following is the logical flow for matching a sequence pattern against a
subject value:

#. If the subject value is not an instance of a
:class:`collections.abc.Sequence` the sequence pattern fails.
#. If the subject value is not a sequence [#]_, the sequence pattern
fails.

#. If the subject value is an instance of ``str``, ``bytes`` or ``bytearray``
the sequence pattern fails.
Expand Down Expand Up @@ -943,7 +943,7 @@ subject value:
In simple terms ``[P1, P2, P3,`` ... ``, P<N>]`` matches only if all the following
happens:

* ``isinstance(<subject>, collections.abc.Sequence)``
* check ``<subject>`` is a sequence
* ``len(subject) == <N>``
* ``P1`` matches ``<subject>[0]`` (note that this match can also bind names)
* ``P2`` matches ``<subject>[1]`` (note that this match can also bind names)
Expand Down Expand Up @@ -975,8 +975,7 @@ runtime error and will raise :exc:`ValueError`.)
The following is the logical flow for matching a mapping pattern against a
subject value:

#. If the subject value is not an instance of :class:`collections.abc.Mapping`,
the mapping pattern fails.
#. If the subject value is not a mapping [#]_,the mapping pattern fails.

#. If every key given in the mapping pattern is present in the subject mapping,
and the pattern for each key matches the corresponding item of the subject
Expand All @@ -993,7 +992,7 @@ subject value:
In simple terms ``{KEY1: P1, KEY2: P2, ... }`` matches only if all the following
happens:

* ``isinstance(<subject>, collections.abc.Mapping)``
* check ``<subject>`` is a mapping
* ``KEY1 in <subject>``
* ``P1`` matches ``<subject>[KEY1]``
* ... and so on for the corresponding KEY/pattern pair.
Expand Down Expand Up @@ -1526,6 +1525,35 @@ body of a coroutine function.
there is a :keyword:`finally` clause which happens to raise another
exception. That new exception causes the old one to be lost.

.. [#] In pattern matching, a sequence is defined as one of the following:

* a class that inherits from :class:`collections.abc.Sequence`
* a Python class that has been registered as :class:`collections.abc.Sequence`
* a builtin class that has its (CPython) :data:`Py_TPFLAGS_SEQUENCE` bit set
* a class that inherits from any of the above

The following standard library classes are sequences:

* :class:`array.array`
* :class:`collections.deque`
* :class:`list`
* :class:`memoryview`
* :class:`range`
* :class:`tuple`

.. note:: Subject values of type ``str``, ``bytes``, and ``bytearray``
do not match sequence patterns.

.. [#] In pattern matching, a mapping is defined as one of the following:

* a class that inherits from :class:`collections.abc.Mapping`
* a Python class that has been registered as :class:`collections.abc.Mapping`
* a builtin class that has its (CPython) :data:`Py_TPFLAGS_MAPPING` bit set
* a class that inherits from any of the above

The standard library classes :class:`dict` and :class:`types.MappingProxyType`
are mappings.

.. [#] A string literal appearing as the first statement in the function body is
transformed into the function's ``__doc__`` attribute and therefore the
function's :term:`docstring`.
Expand Down
2 changes: 1 addition & 1 deletion Doc/reference/simple_stmts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ The :keyword:`!import` statement
: ("," `identifier` ["as" `identifier`])*
: | "from" `relative_module` "import" "(" `identifier` ["as" `identifier`]
: ("," `identifier` ["as" `identifier`])* [","] ")"
: | "from" `module` "import" "*"
: | "from" `relative_module` "import" "*"
module: (`identifier` ".")* `identifier`
relative_module: "."* `module` | "."+

Expand Down
2 changes: 1 addition & 1 deletion Doc/tutorial/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ operator; to calculate the remainder you can use ``%``::
5
>>> 17 % 3 # the % operator returns the remainder of the division
2
>>> 5 * 3 + 2 # result * divisor + remainder
>>> 5 * 3 + 2 # floored quotient * divisor + remainder
17

With Python, it is possible to use the ``**`` operator to calculate powers [#]_::
Expand Down
25 changes: 24 additions & 1 deletion Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ Several other key features:

- Like unpacking assignments, tuple and list patterns have exactly the
same meaning and actually match arbitrary sequences. Technically,
the subject must be an instance of ``collections.abc.Sequence``.
the subject must be a sequence.
Therefore, an important exception is that patterns don't match iterators.
Also, to prevent a common mistake, sequence patterns don't match strings.

Expand Down Expand Up @@ -1089,6 +1089,14 @@ Add :data:`~os.O_EVTONLY`, :data:`~os.O_FSYNC`, :data:`~os.O_SYMLINK`
and :data:`~os.O_NOFOLLOW_ANY` for macOS.
(Contributed by Dong-hee Na in :issue:`43106`.)

os.path
-------

:func:`os.path.realpath` now accepts a *strict* keyword-only argument. When set
to ``True``, :exc:`OSError` is raised if a path doesn't exist or a symlink loop
is encountered.
(Contributed by Barney Gale in :issue:`43757`.)

pathlib
-------

Expand All @@ -1104,6 +1112,11 @@ supersedes :meth:`~pathlib.Path.link_to`. The new method has the same argument
order as :meth:`~pathlib.Path.symlink_to`.
(Contributed by Barney Gale in :issue:`39950`.)

:meth:`pathlib.Path.stat` and :meth:`~pathlib.Path.chmod` now accept a
*follow_symlinks* keyword-only argument for consistency with corresponding
functions in the :mod:`os` module.
(Contributed by Barney Gale in :issue:`39906`.)

platform
--------

Expand Down Expand Up @@ -1833,6 +1846,10 @@ New Features
creating type instances.
(Contributed by Victor Stinner in :issue:`43916`.)

* Add a new :c:data:`Py_TPFLAGS_IMMUTABLETYPE` type flag for creating immutable
type objects: type attributes cannot be set nor deleted.
(Contributed by Victor Stinner and Erlend E. Aasland in :issue:`43908`.)

Porting to Python 3.10
----------------------

Expand Down Expand Up @@ -1890,6 +1907,12 @@ Porting to Python 3.10
been included directly, consider including ``Python.h`` instead.
(Contributed by Nicholas Sim in :issue:`35134`)

* Use the :c:data:`Py_TPFLAGS_IMMUTABLETYPE` type flag to create immutable type
objects. Do not rely on :c:data:`Py_TPFLAGS_HEAPTYPE` to decide if a type
object is mutable or not; check if :c:data:`Py_TPFLAGS_IMMUTABLETYPE` is set
instead.
(Contributed by Victor Stinner and Erlend E. Aasland in :issue:`43908`.)

Deprecated
----------

Expand Down
18 changes: 0 additions & 18 deletions Include/cpython/pyerrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ PyAPI_FUNC(void) _PyErr_GetExcInfo(PyThreadState *, PyObject **, PyObject **, Py

PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);

/* Convenience functions */

#ifdef MS_WINDOWS
Py_DEPRECATED(3.3)
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
PyObject *, const Py_UNICODE *);
#endif /* MS_WINDOWS */

/* Like PyErr_Format(), but saves current exception as __context__ and
__cause__.
*/
Expand All @@ -108,16 +100,6 @@ PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
...
);

#ifdef MS_WINDOWS
/* XXX redeclare to use WSTRING */
Py_DEPRECATED(3.3)
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
int, const Py_UNICODE *);
Py_DEPRECATED(3.3)
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
PyObject *,int, const Py_UNICODE *);
#endif

/* In exceptions.c */

/* Helper that attempts to replace the current exception with one of the
Expand Down
Loading