Skip to content

Commit c0a0c31

Browse files
committed
Merge branch 'master' into sum-complex-121149
2 parents 4c6f4f4 + 7a807c3 commit c0a0c31

File tree

90 files changed

+2150
-1636
lines changed

Some content is hidden

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

90 files changed

+2150
-1636
lines changed

Doc/c-api/dict.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Dictionary Objects
156156
157157
.. c:function:: int PyDict_GetItemStringRef(PyObject *p, const char *key, PyObject **result)
158158
159-
Similar than :c:func:`PyDict_GetItemRef`, but *key* is specified as a
159+
Similar to :c:func:`PyDict_GetItemRef`, but *key* is specified as a
160160
:c:expr:`const char*` UTF-8 encoded bytes string, rather than a
161161
:c:expr:`PyObject*`.
162162
@@ -206,7 +206,7 @@ Dictionary Objects
206206
``NULL``, and return ``0``.
207207
- On error, raise an exception and return ``-1``.
208208
209-
This is similar to :meth:`dict.pop`, but without the default value and
209+
Similar to :meth:`dict.pop`, but without the default value and
210210
not raising :exc:`KeyError` if the key missing.
211211
212212
.. versionadded:: 3.13

Doc/howto/logging.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,44 @@ following diagram.
385385
.. raw:: html
386386
:file: logging_flow.svg
387387

388+
.. raw:: html
389+
390+
<script>
391+
/*
392+
* This snippet is needed to handle the case where a light or dark theme is
393+
* chosen via the theme is selected in the page. We call the existing handler
394+
* and then add a dark-theme class to the body when the dark theme is selected.
395+
* The SVG styling (above) then does the rest.
396+
*
397+
* If the pydoc theme is updated to set the dark-theme class, this snippet
398+
* won't be needed any more.
399+
*/
400+
(function() {
401+
var oldActivateTheme = activateTheme;
402+
403+
function updateBody(theme) {
404+
let elem = document.body;
405+
406+
if (theme === 'dark') {
407+
elem.classList.add('dark-theme');
408+
}
409+
else {
410+
elem.classList.remove('dark-theme');
411+
}
412+
}
413+
414+
activateTheme = function(theme) {
415+
oldActivateTheme(theme);
416+
updateBody(theme);
417+
};
418+
/*
419+
* If the page is refreshed, make sure we update the body - the overriding
420+
* of activateTheme won't have taken effect yet.
421+
*/
422+
updateBody(localStorage.getItem('currentTheme') || 'auto');
423+
})();
424+
</script>
425+
388426
Loggers
389427
^^^^^^^
390428

Doc/howto/logging_flow.svg

Lines changed: 170 additions & 134 deletions
Loading

Doc/library/ctypes.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ Fundamental data types
266266
(1)
267267
The constructor accepts any object with a truth value.
268268

269+
Additionally, if IEC 60559 compatible complex arithmetic (Annex G) is supported, the following
270+
complex types are available:
271+
272+
+----------------------------------+---------------------------------+-----------------+
273+
| ctypes type | C type | Python type |
274+
+==================================+=================================+=================+
275+
| :class:`c_double_complex` | :c:expr:`double complex` | complex |
276+
+----------------------------------+---------------------------------+-----------------+
277+
278+
269279
All these types can be created by calling them with an optional initializer of
270280
the correct type and value::
271281

@@ -2284,6 +2294,14 @@ These are the fundamental ctypes data types:
22842294
optional float initializer.
22852295

22862296

2297+
.. class:: c_double_complex
2298+
2299+
Represents the C :c:expr:`double complex` datatype, if available. The
2300+
constructor accepts an optional :class:`complex` initializer.
2301+
2302+
.. versionadded:: 3.14
2303+
2304+
22872305
.. class:: c_int
22882306

22892307
Represents the C :c:expr:`signed int` datatype. The constructor accepts an

Doc/library/os.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4642,6 +4642,10 @@ written in Python, such as a mail server's external command delivery program.
46424642
Use :class:`subprocess.Popen` or :func:`subprocess.run` to
46434643
control options like encodings.
46444644

4645+
.. deprecated:: 3.14
4646+
The function is :term:`soft deprecated` and should no longer be used to
4647+
write new code. The :mod:`subprocess` module is recommended instead.
4648+
46454649

46464650
.. function:: posix_spawn(path, argv, env, *, file_actions=None, \
46474651
setpgroup=None, resetids=False, setsid=False, setsigmask=(), \
@@ -4868,6 +4872,10 @@ written in Python, such as a mail server's external command delivery program.
48684872
.. versionchanged:: 3.6
48694873
Accepts a :term:`path-like object`.
48704874

4875+
.. deprecated:: 3.14
4876+
These functions are :term:`soft deprecated` and should no longer be used
4877+
to write new code. The :mod:`subprocess` module is recommended instead.
4878+
48714879

48724880
.. data:: P_NOWAIT
48734881
P_NOWAITO
@@ -4972,7 +4980,7 @@ written in Python, such as a mail server's external command delivery program.
49724980
shell documentation.
49734981

49744982
The :mod:`subprocess` module provides more powerful facilities for spawning
4975-
new processes and retrieving their results; using that module is preferable
4983+
new processes and retrieving their results; using that module is recommended
49764984
to using this function. See the :ref:`subprocess-replacements` section in
49774985
the :mod:`subprocess` documentation for some helpful recipes.
49784986

Doc/library/pathlib.rst

Lines changed: 107 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ inherit from pure paths but also provide I/O operations.
2121
.. image:: pathlib-inheritance.png
2222
:align: center
2323
:class: invert-in-dark-mode
24+
:alt: Inheritance diagram showing the classes available in pathlib. The
25+
most basic class is PurePath, which has three direct subclasses:
26+
PurePosixPath, PureWindowsPath, and Path. Further to these four
27+
classes, there are two classes that use multiple inheritance:
28+
PosixPath subclasses PurePosixPath and Path, and WindowsPath
29+
subclasses PureWindowsPath and Path.
2430

2531
If you've never used this module before or just aren't sure which class is
2632
right for your task, :class:`Path` is most likely what you need. It instantiates
@@ -885,6 +891,107 @@ conforming to :rfc:`8089`.
885891
it strictly impure.
886892

887893

894+
Expanding and resolving paths
895+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
896+
897+
.. classmethod:: Path.home()
898+
899+
Return a new path object representing the user's home directory (as
900+
returned by :func:`os.path.expanduser` with ``~`` construct). If the home
901+
directory can't be resolved, :exc:`RuntimeError` is raised.
902+
903+
::
904+
905+
>>> Path.home()
906+
PosixPath('/home/antoine')
907+
908+
.. versionadded:: 3.5
909+
910+
911+
.. method:: Path.expanduser()
912+
913+
Return a new path with expanded ``~`` and ``~user`` constructs,
914+
as returned by :meth:`os.path.expanduser`. If a home directory can't be
915+
resolved, :exc:`RuntimeError` is raised.
916+
917+
::
918+
919+
>>> p = PosixPath('~/films/Monty Python')
920+
>>> p.expanduser()
921+
PosixPath('/home/eric/films/Monty Python')
922+
923+
.. versionadded:: 3.5
924+
925+
926+
.. classmethod:: Path.cwd()
927+
928+
Return a new path object representing the current directory (as returned
929+
by :func:`os.getcwd`)::
930+
931+
>>> Path.cwd()
932+
PosixPath('/home/antoine/pathlib')
933+
934+
935+
.. method:: Path.absolute()
936+
937+
Make the path absolute, without normalization or resolving symlinks.
938+
Returns a new path object::
939+
940+
>>> p = Path('tests')
941+
>>> p
942+
PosixPath('tests')
943+
>>> p.absolute()
944+
PosixPath('/home/antoine/pathlib/tests')
945+
946+
947+
.. method:: Path.resolve(strict=False)
948+
949+
Make the path absolute, resolving any symlinks. A new path object is
950+
returned::
951+
952+
>>> p = Path()
953+
>>> p
954+
PosixPath('.')
955+
>>> p.resolve()
956+
PosixPath('/home/antoine/pathlib')
957+
958+
"``..``" components are also eliminated (this is the only method to do so)::
959+
960+
>>> p = Path('docs/../setup.py')
961+
>>> p.resolve()
962+
PosixPath('/home/antoine/pathlib/setup.py')
963+
964+
If a path doesn't exist or a symlink loop is encountered, and *strict* is
965+
``True``, :exc:`OSError` is raised. If *strict* is ``False``, the path is
966+
resolved as far as possible and any remainder is appended without checking
967+
whether it exists.
968+
969+
.. versionchanged:: 3.6
970+
The *strict* parameter was added (pre-3.6 behavior is strict).
971+
972+
.. versionchanged:: 3.13
973+
Symlink loops are treated like other errors: :exc:`OSError` is raised in
974+
strict mode, and no exception is raised in non-strict mode. In previous
975+
versions, :exc:`RuntimeError` is raised no matter the value of *strict*.
976+
977+
978+
.. method:: Path.readlink()
979+
980+
Return the path to which the symbolic link points (as returned by
981+
:func:`os.readlink`)::
982+
983+
>>> p = Path('mylink')
984+
>>> p.symlink_to('setup.py')
985+
>>> p.readlink()
986+
PosixPath('setup.py')
987+
988+
.. versionadded:: 3.9
989+
990+
.. versionchanged:: 3.13
991+
Raises :exc:`UnsupportedOperation` if :func:`os.readlink` is not
992+
available. In previous versions, :exc:`NotImplementedError` was raised.
993+
994+
888995
Querying file type and status
889996
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
890997

@@ -1605,107 +1712,6 @@ Permissions and ownership
16051712
symbolic link's mode is changed rather than its target's.
16061713

16071714

1608-
Other methods
1609-
^^^^^^^^^^^^^
1610-
1611-
.. classmethod:: Path.cwd()
1612-
1613-
Return a new path object representing the current directory (as returned
1614-
by :func:`os.getcwd`)::
1615-
1616-
>>> Path.cwd()
1617-
PosixPath('/home/antoine/pathlib')
1618-
1619-
1620-
.. classmethod:: Path.home()
1621-
1622-
Return a new path object representing the user's home directory (as
1623-
returned by :func:`os.path.expanduser` with ``~`` construct). If the home
1624-
directory can't be resolved, :exc:`RuntimeError` is raised.
1625-
1626-
::
1627-
1628-
>>> Path.home()
1629-
PosixPath('/home/antoine')
1630-
1631-
.. versionadded:: 3.5
1632-
1633-
1634-
.. method:: Path.expanduser()
1635-
1636-
Return a new path with expanded ``~`` and ``~user`` constructs,
1637-
as returned by :meth:`os.path.expanduser`. If a home directory can't be
1638-
resolved, :exc:`RuntimeError` is raised.
1639-
1640-
::
1641-
1642-
>>> p = PosixPath('~/films/Monty Python')
1643-
>>> p.expanduser()
1644-
PosixPath('/home/eric/films/Monty Python')
1645-
1646-
.. versionadded:: 3.5
1647-
1648-
1649-
.. method:: Path.readlink()
1650-
1651-
Return the path to which the symbolic link points (as returned by
1652-
:func:`os.readlink`)::
1653-
1654-
>>> p = Path('mylink')
1655-
>>> p.symlink_to('setup.py')
1656-
>>> p.readlink()
1657-
PosixPath('setup.py')
1658-
1659-
.. versionadded:: 3.9
1660-
1661-
.. versionchanged:: 3.13
1662-
Raises :exc:`UnsupportedOperation` if :func:`os.readlink` is not
1663-
available. In previous versions, :exc:`NotImplementedError` was raised.
1664-
1665-
1666-
.. method:: Path.absolute()
1667-
1668-
Make the path absolute, without normalization or resolving symlinks.
1669-
Returns a new path object::
1670-
1671-
>>> p = Path('tests')
1672-
>>> p
1673-
PosixPath('tests')
1674-
>>> p.absolute()
1675-
PosixPath('/home/antoine/pathlib/tests')
1676-
1677-
1678-
.. method:: Path.resolve(strict=False)
1679-
1680-
Make the path absolute, resolving any symlinks. A new path object is
1681-
returned::
1682-
1683-
>>> p = Path()
1684-
>>> p
1685-
PosixPath('.')
1686-
>>> p.resolve()
1687-
PosixPath('/home/antoine/pathlib')
1688-
1689-
"``..``" components are also eliminated (this is the only method to do so)::
1690-
1691-
>>> p = Path('docs/../setup.py')
1692-
>>> p.resolve()
1693-
PosixPath('/home/antoine/pathlib/setup.py')
1694-
1695-
If a path doesn't exist or a symlink loop is encountered, and *strict* is
1696-
``True``, :exc:`OSError` is raised. If *strict* is ``False``, the path is
1697-
resolved as far as possible and any remainder is appended without checking
1698-
whether it exists.
1699-
1700-
.. versionchanged:: 3.6
1701-
The *strict* parameter was added (pre-3.6 behavior is strict).
1702-
1703-
.. versionchanged:: 3.13
1704-
Symlink loops are treated like other errors: :exc:`OSError` is raised in
1705-
strict mode, and no exception is raised in non-strict mode. In previous
1706-
versions, :exc:`RuntimeError` is raised no matter the value of *strict*.
1707-
1708-
17091715
.. _pathlib-pattern-language:
17101716

17111717
Pattern language

Doc/library/stdtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4565,7 +4565,7 @@ can be used interchangeably to index the same dictionary entry.
45654565

45664566
Return a shallow copy of the dictionary.
45674567

4568-
.. classmethod:: fromkeys(iterable, value=None)
4568+
.. classmethod:: fromkeys(iterable, value=None, /)
45694569

45704570
Create a new dictionary with keys from *iterable* and values set to *value*.
45714571

Doc/library/urllib.parse.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ to an absolute URL given a "base URL."
2222

2323
The module has been designed to match the internet RFC on Relative Uniform
2424
Resource Locators. It supports the following URL schemes: ``file``, ``ftp``,
25-
``gopher``, ``hdl``, ``http``, ``https``, ``imap``, ``mailto``, ``mms``,
25+
``gopher``, ``hdl``, ``http``, ``https``, ``imap``, ``itms-services``, ``mailto``, ``mms``,
2626
``news``, ``nntp``, ``prospero``, ``rsync``, ``rtsp``, ``rtsps``, ``rtspu``,
2727
``sftp``, ``shttp``, ``sip``, ``sips``, ``snews``, ``svn``, ``svn+ssh``,
2828
``telnet``, ``wais``, ``ws``, ``wss``.
2929

30+
.. impl-detail::
31+
32+
The inclusion of the ``itms-services`` URL scheme can prevent an app from
33+
passing Apple's App Store review process for the macOS and iOS App Stores.
34+
Handling for the ``itms-services`` scheme is always removed on iOS; on
35+
macOS, it *may* be removed if CPython has been built with the
36+
:option:`--with-app-store-compliance` option.
37+
3038
The :mod:`urllib.parse` module defines functions that fall into two broad
3139
categories: URL parsing and URL quoting. These are covered in detail in
3240
the following sections.

Doc/library/warnings.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ the disposition of the match. Each entry is a tuple of the form (*action*,
145145
+---------------+----------------------------------------------+
146146
| ``"always"`` | always print matching warnings |
147147
+---------------+----------------------------------------------+
148+
| ``"all"`` | alias to "always" |
149+
+---------------+----------------------------------------------+
148150
| ``"module"`` | print the first occurrence of matching |
149151
| | warnings for each module where the warning |
150152
| | is issued (regardless of line number) |

0 commit comments

Comments
 (0)