Skip to content

Commit 7537c86

Browse files
committed
Merge remote-tracking branch 'origin/master' into bpo_41073_add_typeslots1
* origin/master: (63 commits) bpo-41627: Distinguish 32 and 64-bit user site packages on Windows (pythonGH-22098) bpo-38585: Remove references to defusedexpat (pythonGH-22095) bpo-41721: Add xlc options (pythonGH-22096) bpo-40486: Specify what happens if directory content change diring iteration (pythonGH-22025) bpo-41638: Improve ProgrammingError message for absent parameter. (pythonGH-21999) bpo-41713: _signal doesn't use multi-phase init (pythonGH-22087) bpo-41700: Skip test if the locale is not supported (pythonGH-22081) [doc] Update documentation on logging optimization. (pythonGH-22075) Fix 'gather' rules in the python parser generator (pythonGH-22021) bpo-41697: Correctly handle KeywordOrStarred when parsing arguments in the parser (pythonGH-22077) [doc] Fix a typo in the graphlib docs (python#22030) bpo-1635741: Port _signal module to multi-phase init (PEP 489) (pythonGH-22049) bpo-39883: Use BSD0 license for code in docs (pythonGH-17635) bpo-39010: Improve test shutdown (python#22066) bpo-41696: Fix handling of debug mode in asyncio.run (python#22069) bpo-41690: Use a loop to collect args in the parser instead of recursion (pythonGH-22053) closes bpo-41689: Preserve text signature from tp_doc in C heap type creation. (pythonGH-22058) Fix invalid escape sequences in the peg_highlight Sphinx extension (pythonGH-22047) bpo-41675: Modernize siginterrupt calls (pythonGH-22028) bpo-41685: Don't pin setuptools version anymore in Doc/Makefile (pythonGH-22062) ...
2 parents eb3907d + dd18001 commit 7537c86

File tree

99 files changed

+2019
-1205
lines changed

Some content is hidden

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

99 files changed

+2019
-1205
lines changed

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ clean:
143143
venv:
144144
$(PYTHON) -m venv $(VENVDIR)
145145
$(VENVDIR)/bin/python3 -m pip install -U pip setuptools
146-
$(VENVDIR)/bin/python3 -m pip install -U Sphinx==2.3.1 blurb python-docs-theme
146+
$(VENVDIR)/bin/python3 -m pip install -U Sphinx==3.2.1 blurb python-docs-theme
147147
@echo "The venv has been created in the $(VENVDIR) directory"
148148

149149
dist:

Doc/c-api/type.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ Type Objects
118118
If no module is associated with the given type, sets :py:class:`TypeError`
119119
and returns ``NULL``.
120120
121+
This function is usually used to get the module in which a method is defined.
122+
Note that in such a method, ``PyType_GetModule(Py_TYPE(self))``
123+
may not return the intended result.
124+
``Py_TYPE(self)`` may be a *subclass* of the intended class, and subclasses
125+
are not necessarily defined in the same module as their superclass.
126+
See :c:type:`PyCMethod` to get the class that defines the method.
127+
121128
.. versionadded:: 3.9
122129
123130
.. c:function:: void* PyType_GetModuleState(PyTypeObject *type)
@@ -152,9 +159,12 @@ The following functions and structs are used to create
152159
If *bases* is ``NULL``, the *Py_tp_base* slot is used instead.
153160
If that also is ``NULL``, the new type derives from :class:`object`.
154161
155-
The *module* must be a module object or ``NULL``.
162+
The *module* argument can be used to record the module in which the new
163+
class is defined. It must be a module object or ``NULL``.
156164
If not ``NULL``, the module is associated with the new type and can later be
157165
retreived with :c:func:`PyType_GetModule`.
166+
The associated module is not inherited by subclasses; it must be specified
167+
for each class individually.
158168
159169
This function calls :c:func:`PyType_Ready` on the new type.
160170
@@ -216,7 +226,8 @@ The following functions and structs are used to create
216226
* ``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`
217227
* ``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`
218228
219-
The following fields cannot be set using :c:type:`PyType_Spec` and :c:type:`PyType_Slot`:
229+
The following fields cannot be set at all using :c:type:`PyType_Spec` and
230+
:c:type:`PyType_Slot`:
220231
221232
* :c:member:`~PyTypeObject.tp_dict`
222233
* :c:member:`~PyTypeObject.tp_mro`
@@ -230,13 +241,21 @@ The following functions and structs are used to create
230241
(see :ref:`PyMemberDef <pymemberdef-offsets>`)
231242
* :c:member:`~PyTypeObject.tp_vectorcall_offset`
232243
(see :ref:`PyMemberDef <pymemberdef-offsets>`)
244+
245+
The following fields cannot be set using :c:type:`PyType_Spec` and
246+
:c:type:`PyType_Slot` under the limited API:
247+
233248
* :c:member:`~PyBufferProcs.bf_getbuffer`
234249
* :c:member:`~PyBufferProcs.bf_releasebuffer`
235250
236251
Setting :c:data:`Py_tp_bases` may be problematic on some platforms.
237252
To avoid issues, use the *bases* argument of
238253
:py:func:`PyType_FromSpecWithBases` instead.
239254
255+
.. versionchanged:: 3.9
256+
257+
Slots in :c:type:`PyBufferProcs` in may be set in the unlimited API.
258+
240259
.. c:member:: void *PyType_Slot.pfunc
241260
242261
The desired value of the slot. In most cases, this is a pointer

Doc/faq/design.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,7 @@ whether an instance or a class implements a particular ABC. The
573573
:class:`~collections.abc.MutableMapping`.
574574

575575
For Python, many of the advantages of interface specifications can be obtained
576-
by an appropriate test discipline for components. There is also a tool,
577-
PyChecker, which can be used to find problems due to subclassing.
576+
by an appropriate test discipline for components.
578577

579578
A good test suite for a module can both provide a regression test and serve as a
580579
module interface specification and a set of examples. Many Python modules can

Doc/faq/general.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ to fix critical bugs.
142142
Alpha, beta and release candidate versions have an additional suffix. The
143143
suffix for an alpha version is "aN" for some small number N, the suffix for a
144144
beta version is "bN" for some small number N, and the suffix for a release
145-
candidate version is "cN" for some small number N. In other words, all versions
145+
candidate version is "rcN" for some small number N. In other words, all versions
146146
labeled 2.0aN precede the versions labeled 2.0bN, which precede versions labeled
147-
2.0cN, and *those* precede 2.0.
147+
2.0rcN, and *those* precede 2.0.
148148

149149
You may also find version numbers with a "+" suffix, e.g. "2.2+". These are
150150
unreleased versions, built directly from the CPython development repository. In
@@ -309,8 +309,8 @@ releases.
309309
The latest stable releases can always be found on the `Python download page
310310
<https://www.python.org/downloads/>`_. There are two production-ready versions
311311
of Python: 2.x and 3.x. The recommended version is 3.x, which is supported by
312-
most widely used libraries. Although 2.x is still widely used, `it will not
313-
be maintained after January 1, 2020 <https://www.python.org/dev/peps/pep-0373/>`_.
312+
most widely used libraries. Although 2.x is still widely used, `it is not
313+
maintained anymore <https://www.python.org/dev/peps/pep-0373/>`_.
314314

315315
How many people are using Python?
316316
---------------------------------

Doc/faq/programming.rst

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ for Windows Extensions <https://sourceforge.net/projects/pywin32/>`__ project an
3535
as a part of the ActivePython distribution (see
3636
https://www.activestate.com/activepython\ ).
3737

38-
`Boa Constructor <http://boa-constructor.sourceforge.net/>`_ is an IDE and GUI
39-
builder that uses wxWidgets. It offers visual frame creation and manipulation,
40-
an object inspector, many views on the source like object browsers, inheritance
41-
hierarchies, doc string generated html documentation, an advanced debugger,
42-
integrated help, and Zope support.
43-
4438
`Eric <http://eric-ide.python-projects.org/>`_ is an IDE built on PyQt
4539
and the Scintilla editing component.
4640

@@ -57,22 +51,14 @@ They include:
5751
* PyCharm (https://www.jetbrains.com/pycharm/)
5852

5953

60-
Is there a tool to help find bugs or perform static analysis?
54+
Are there tools to help find bugs or perform static analysis?
6155
-------------------------------------------------------------
6256

6357
Yes.
6458

65-
PyChecker is a static analysis tool that finds bugs in Python source code and
66-
warns about code complexity and style. You can get PyChecker from
67-
http://pychecker.sourceforge.net/.
68-
69-
`Pylint <https://www.pylint.org/>`_ is another tool that checks
70-
if a module satisfies a coding standard, and also makes it possible to write
71-
plug-ins to add a custom feature. In addition to the bug checking that
72-
PyChecker performs, Pylint offers some additional features such as checking line
73-
length, whether variable names are well-formed according to your coding
74-
standard, whether declared interfaces are fully implemented, and more.
75-
https://docs.pylint.org/ provides a full list of Pylint's features.
59+
`Pylint <https://www.pylint.org/>`_ and
60+
`Pyflakes <https://github.com/PyCQA/pyflakes>`_ do basic checking that will
61+
help you catch bugs sooner.
7662

7763
Static type checkers such as `Mypy <http://mypy-lang.org/>`_,
7864
`Pyre <https://pyre-check.org/>`_, and

Doc/howto/logging.rst

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,20 +1078,22 @@ need more precise control over what logging information is collected. Here's a
10781078
list of things you can do to avoid processing during logging which you don't
10791079
need:
10801080

1081-
+-----------------------------------------------+----------------------------------------+
1082-
| What you don't want to collect | How to avoid collecting it |
1083-
+===============================================+========================================+
1084-
| Information about where calls were made from. | Set ``logging._srcfile`` to ``None``. |
1085-
| | This avoids calling |
1086-
| | :func:`sys._getframe`, which may help |
1087-
| | to speed up your code in environments |
1088-
| | like PyPy (which can't speed up code |
1089-
| | that uses :func:`sys._getframe`). |
1090-
+-----------------------------------------------+----------------------------------------+
1091-
| Threading information. | Set ``logging.logThreads`` to ``0``. |
1092-
+-----------------------------------------------+----------------------------------------+
1093-
| Process information. | Set ``logging.logProcesses`` to ``0``. |
1094-
+-----------------------------------------------+----------------------------------------+
1081+
+-----------------------------------------------------+---------------------------------------------------+
1082+
| What you don't want to collect | How to avoid collecting it |
1083+
+=====================================================+===================================================+
1084+
| Information about where calls were made from. | Set ``logging._srcfile`` to ``None``. |
1085+
| | This avoids calling :func:`sys._getframe`, which |
1086+
| | may help to speed up your code in environments |
1087+
| | like PyPy (which can't speed up code that uses |
1088+
| | :func:`sys._getframe`). |
1089+
+-----------------------------------------------------+---------------------------------------------------+
1090+
| Threading information. | Set ``logging.logThreads`` to ``False``. |
1091+
+-----------------------------------------------------+---------------------------------------------------+
1092+
| Current process ID (:func:`os.getpid`) | Set ``logging.logProcesses`` to ``False``. |
1093+
+-----------------------------------------------------+---------------------------------------------------+
1094+
| Current process name when using ``multiprocessing`` | Set ``logging.logMultiprocessing`` to ``False``. |
1095+
| to manage multiple processes. | |
1096+
+-----------------------------------------------------+---------------------------------------------------+
10951097

10961098
Also note that the core logging module only includes the basic handlers. If
10971099
you don't import :mod:`logging.handlers` and :mod:`logging.config`, they won't

Doc/library/argparse.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,8 +1162,8 @@ keyword argument to :meth:`~ArgumentParser.add_argument`::
11621162
>>> parser.parse_args(['--foo', 'BAR'])
11631163
Namespace(foo='BAR')
11641164
>>> parser.parse_args([])
1165-
usage: argparse.py [-h] [--foo FOO]
1166-
argparse.py: error: option --foo is required
1165+
usage: [-h] --foo FOO
1166+
: error: the following arguments are required: --foo
11671167

11681168
As the example shows, if an option is marked as ``required``,
11691169
:meth:`~ArgumentParser.parse_args` will report an error if that option is not

Doc/library/asyncio-dev.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ The :meth:`loop.run_in_executor` method can be used with a
107107
blocking code in a different OS thread without blocking the OS thread
108108
that the event loop runs in.
109109

110+
There is currently no way to schedule coroutines or callbacks directly
111+
from a different process (such as one started with
112+
:mod:`multiprocessing`). The :ref:`Event Loop Methods <asyncio-event-loop>`
113+
section lists APIs that can read from pipes and watch file descriptors
114+
without blocking the event loop. In addition, asyncio's
115+
:ref:`Subprocess <asyncio-subprocess>` APIs provide a way to start a
116+
process and communicate with it from the event loop. Lastly, the
117+
aforementioned :meth:`loop.run_in_executor` method can also be used
118+
with a :class:`concurrent.futures.ProcessPoolExecutor` to execute
119+
code in a different process.
110120

111121
.. _asyncio-handle-blocking:
112122

Doc/library/curses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ the following methods and attributes:
717717
window.addch(y, x, ch[, attr])
718718

719719
Paint character *ch* at ``(y, x)`` with attributes *attr*, overwriting any
720-
character previously painter at that location. By default, the character
720+
character previously painted at that location. By default, the character
721721
position and attributes are the current settings for the window object.
722722

723723
.. note::

Doc/library/functions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,9 @@ are always available. They are listed here in alphabetical order.
17341734
locals dictionary is only useful for reads since updates to the locals
17351735
dictionary are ignored.
17361736

1737+
A :exc:`TypeError` exception is raised if an object is specified but
1738+
it doesn't have a :attr:`~object.__dict__` attribute (for example, if
1739+
its class defines the :attr:`~object.__slots__` attribute).
17371740

17381741
.. function:: zip(*iterables, strict=False)
17391742

Doc/library/glob.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ For example, ``'[?]'`` matches the character ``'?'``.
4343
(like :file:`/usr/src/Python-1.5/Makefile`) or relative (like
4444
:file:`../../Tools/\*/\*.gif`), and can contain shell-style wildcards. Broken
4545
symlinks are included in the results (as in the shell). Whether or not the
46-
results are sorted depends on the file system.
46+
results are sorted depends on the file system. If a file that satisfies
47+
conditions is removed or added during the call of this function, whether
48+
a path name for that file be included is unspecified.
4749

4850
If *root_dir* is not ``None``, it should be a :term:`path-like object`
4951
specifying the root directory for searching. It has the same effect on

Doc/library/graphlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
if ts.is_active():
122122
...
123123

124-
if possible to simply do::
124+
it is possible to simply do::
125125

126126
if ts:
127127
...

Doc/library/json.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ Command line options
745745

746746
.. cmdoption:: --indent, --tab, --no-indent, --compact
747747

748-
Mutually exclusive options for whitespace control
748+
Mutually exclusive options for whitespace control.
749749

750750
.. versionadded:: 3.9
751751

Doc/library/logging.rst

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,9 @@ functions.
11661166
+--------------+---------------------------------------------+
11671167
| Format | Description |
11681168
+==============+=============================================+
1169-
| *filename* | Specifies that a FileHandler be created, |
1170-
| | using the specified filename, rather than a |
1171-
| | StreamHandler. |
1169+
| *filename* | Specifies that a :class:`FileHandler` be |
1170+
| | created, using the specified filename, |
1171+
| | rather than a :class:`StreamHandler`. |
11721172
+--------------+---------------------------------------------+
11731173
| *filemode* | If *filename* is specified, open the file |
11741174
| | in this :ref:`mode <filemodes>`. Defaults |
@@ -1192,9 +1192,10 @@ functions.
11921192
| | :ref:`level <levels>`. |
11931193
+--------------+---------------------------------------------+
11941194
| *stream* | Use the specified stream to initialize the |
1195-
| | StreamHandler. Note that this argument is |
1196-
| | incompatible with *filename* - if both |
1197-
| | are present, a ``ValueError`` is raised. |
1195+
| | :class:`StreamHandler`. Note that this |
1196+
| | argument is incompatible with *filename* - |
1197+
| | if both are present, a ``ValueError`` is |
1198+
| | raised. |
11981199
+--------------+---------------------------------------------+
11991200
| *handlers* | If specified, this should be an iterable of |
12001201
| | already created handlers to add to the root |
@@ -1213,18 +1214,18 @@ functions.
12131214
+--------------+---------------------------------------------+
12141215
| *encoding* | If this keyword argument is specified along |
12151216
| | with *filename*, its value is used when the |
1216-
| | FileHandler is created, and thus used when |
1217-
| | opening the output file. |
1217+
| | :class:`FileHandler` is created, and thus |
1218+
| | used when opening the output file. |
12181219
+--------------+---------------------------------------------+
12191220
| *errors* | If this keyword argument is specified along |
12201221
| | with *filename*, its value is used when the |
1221-
| | FileHandler is created, and thus used when |
1222-
| | opening the output file. If not specified, |
1223-
| | the value 'backslashreplace' is used. Note |
1224-
| | that if ``None`` is specified, it will be |
1225-
| | passed as such to func:`open`, which means |
1226-
| | that it will be treated the same as passing |
1227-
| | 'errors'. |
1222+
| | :class:`FileHandler` is created, and thus |
1223+
| | used when opening the output file. If not |
1224+
| | specified, the value 'backslashreplace' is |
1225+
| | used. Note that if ``None`` is specified, |
1226+
| | it will be passed as such to :func:`open`, |
1227+
| | which means that it will be treated the |
1228+
| | same as passing 'errors'. |
12281229
+--------------+---------------------------------------------+
12291230

12301231
.. versionchanged:: 3.2

Doc/library/multiprocessing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ For an example of the usage of queues for interprocess communication see
861861

862862
A better name for this method might be
863863
``allow_exit_without_flush()``. It is likely to cause enqueued
864-
data to lost, and you almost certainly will not need to use it.
864+
data to be lost, and you almost certainly will not need to use it.
865865
It is really only there if you need the current process to exit
866866
immediately without waiting to flush enqueued data to the
867867
underlying pipe, and you don't care about lost data.

Doc/library/os.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,8 @@ features:
18521852
Return a list containing the names of the entries in the directory given by
18531853
*path*. The list is in arbitrary order, and does not include the special
18541854
entries ``'.'`` and ``'..'`` even if they are present in the directory.
1855+
If a file is removed from or added to the directory during the call of
1856+
this function, whether a name for that file be included is unspecified.
18551857

18561858
*path* may be a :term:`path-like object`. If *path* is of type ``bytes``
18571859
(directly or indirectly through the :class:`PathLike` interface),
@@ -2257,7 +2259,9 @@ features:
22572259
Return an iterator of :class:`os.DirEntry` objects corresponding to the
22582260
entries in the directory given by *path*. The entries are yielded in
22592261
arbitrary order, and the special entries ``'.'`` and ``'..'`` are not
2260-
included.
2262+
included. If a file is removed from or added to the directory after
2263+
creating the iterator, whether an entry for that file be included is
2264+
unspecified.
22612265

22622266
Using :func:`scandir` instead of :func:`listdir` can significantly
22632267
increase the performance of code that also needs file type or file
@@ -3007,7 +3011,10 @@ features:
30073011
*filenames* is a list of the names of the non-directory files in *dirpath*.
30083012
Note that the names in the lists contain no path components. To get a full path
30093013
(which begins with *top*) to a file or directory in *dirpath*, do
3010-
``os.path.join(dirpath, name)``.
3014+
``os.path.join(dirpath, name)``. Whether or not the lists are sorted
3015+
depends on the file system. If a file is removed from or added to the
3016+
*dirpath* directory during generating the lists, whether a name for that
3017+
file be included is unspecified.
30113018

30123019
If optional argument *topdown* is ``True`` or not specified, the triple for a
30133020
directory is generated before the triples for any of its subdirectories

Doc/library/pathlib.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,11 @@ call fails (for example because the path doesn't exist).
890890
PosixPath('docs/_static')
891891
PosixPath('docs/Makefile')
892892

893+
The children are yielded in arbitrary order, and the special entries
894+
``'.'`` and ``'..'`` are not included. If a file is removed from or added
895+
to the directory after creating the iterator, whether an path object for
896+
that file be included is unspecified.
897+
893898
.. method:: Path.lchmod(mode)
894899

895900
Like :meth:`Path.chmod` but, if the path points to a symbolic link, the

0 commit comments

Comments
 (0)