Skip to content

Commit e37a82a

Browse files
committed
Merge branch 'master' of git://github.com/python/cpython into pymain-run-module-sigint
2 parents c483f65 + 7219e27 commit e37a82a

File tree

242 files changed

+6292
-3817
lines changed

Some content is hidden

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

242 files changed

+6292
-3817
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
@@ -117,6 +117,13 @@ Type Objects
117117
If no module is associated with the given type, sets :py:class:`TypeError`
118118
and returns ``NULL``.
119119
120+
This function is usually used to get the module in which a method is defined.
121+
Note that in such a method, ``PyType_GetModule(Py_TYPE(self))``
122+
may not return the intended result.
123+
``Py_TYPE(self)`` may be a *subclass* of the intended class, and subclasses
124+
are not necessarily defined in the same module as their superclass.
125+
See :c:type:`PyCMethod` to get the class that defines the method.
126+
120127
.. versionadded:: 3.9
121128
122129
.. c:function:: void* PyType_GetModuleState(PyTypeObject *type)
@@ -151,9 +158,12 @@ The following functions and structs are used to create
151158
If *bases* is ``NULL``, the *Py_tp_base* slot is used instead.
152159
If that also is ``NULL``, the new type derives from :class:`object`.
153160
154-
The *module* must be a module object or ``NULL``.
161+
The *module* argument can be used to record the module in which the new
162+
class is defined. It must be a module object or ``NULL``.
155163
If not ``NULL``, the module is associated with the new type and can later be
156164
retreived with :c:func:`PyType_GetModule`.
165+
The associated module is not inherited by subclasses; it must be specified
166+
for each class individually.
157167
158168
This function calls :c:func:`PyType_Ready` on the new type.
159169
@@ -215,7 +225,8 @@ The following functions and structs are used to create
215225
* ``Py_nb_add`` to set :c:member:`PyNumberMethods.nb_add`
216226
* ``Py_sq_length`` to set :c:member:`PySequenceMethods.sq_length`
217227
218-
The following fields cannot be set using :c:type:`PyType_Spec` and :c:type:`PyType_Slot`:
228+
The following fields cannot be set at all using :c:type:`PyType_Spec` and
229+
:c:type:`PyType_Slot`:
219230
220231
* :c:member:`~PyTypeObject.tp_dict`
221232
* :c:member:`~PyTypeObject.tp_mro`
@@ -229,13 +240,21 @@ The following functions and structs are used to create
229240
(see :ref:`PyMemberDef <pymemberdef-offsets>`)
230241
* :c:member:`~PyTypeObject.tp_vectorcall_offset`
231242
(see :ref:`PyMemberDef <pymemberdef-offsets>`)
243+
244+
The following fields cannot be set using :c:type:`PyType_Spec` and
245+
:c:type:`PyType_Slot` under the limited API:
246+
232247
* :c:member:`~PyBufferProcs.bf_getbuffer`
233248
* :c:member:`~PyBufferProcs.bf_releasebuffer`
234249
235250
Setting :c:data:`Py_tp_bases` may be problematic on some platforms.
236251
To avoid issues, use the *bases* argument of
237252
:py:func:`PyType_FromSpecWithBases` instead.
238253
254+
.. versionchanged:: 3.9
255+
256+
Slots in :c:type:`PyBufferProcs` in may be set in the unlimited API.
257+
239258
.. c:member:: void *PyType_Slot.pfunc
240259
241260
The desired value of the slot. In most cases, this is a pointer

Doc/data/refcounts.dat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,6 +2283,11 @@ PyType_CheckExact:PyObject*:o:0:
22832283
PyType_FromSpec:PyObject*::+1:
22842284
PyType_FromSpec:PyType_Spec*:spec::
22852285

2286+
PyType_FromModuleAndSpec:PyObject*::+1:
2287+
PyType_FromModuleAndSpec:PyObject*:module:+1:
2288+
PyType_FromModuleAndSpec:PyType_Spec*:spec::
2289+
PyType_FromModuleAndSpec:PyObject*:bases:0:
2290+
22862291
PyType_FromSpecWithBases:PyObject*::+1:
22872292
PyType_FromSpecWithBases:PyType_Spec*:spec::
22882293
PyType_FromSpecWithBases:PyObject*:bases:0:

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/programming.rst

Lines changed: 5 additions & 19 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
@@ -1155,7 +1141,7 @@ How do you remove duplicates from a list?
11551141

11561142
See the Python Cookbook for a long discussion of many ways to do this:
11571143

1158-
https://code.activestate.com/recipes/52560/
1144+
https://github.com/ActiveState/code/tree/master/recipes/Python/52560_Remove_duplicates/recipe-52560.py
11591145

11601146
If you don't mind reordering the list, sort it and then scan from the end of the
11611147
list, deleting duplicates as you go::

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/howto/urllib2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,5 +601,5 @@ This document was reviewed and revised by John Lee.
601601
scripts with a localhost server, I have to prevent urllib from using
602602
the proxy.
603603
.. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe
604-
<https://code.activestate.com/recipes/456195/>`_.
604+
<https://github.com/ActiveState/code/tree/master/recipes/Python/456195_urrlib2_opener_SSL_proxy_CONNECT/recipe-456195.py>`_.
605605

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/bisect.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ The following functions are provided:
6060
.. seealso::
6161

6262
`SortedCollection recipe
63-
<https://code.activestate.com/recipes/577197-sortedcollection/>`_ that uses
63+
<https://github.com/ActiveState/code/tree/master/recipes/Python/577197_SortedCollection/recipe-577197.py>`_ that uses
6464
bisect to build a full-featured collection class with straight-forward search
6565
methods and support for a key-function. The keys are precomputed to save
6666
unnecessary calls to the key function during searches.

Doc/library/collections.abc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ Notes on using :class:`Set` and :class:`MutableSet` as a mixin:
308308

309309
.. seealso::
310310

311-
* `OrderedSet recipe <https://code.activestate.com/recipes/576694/>`_ for an
311+
* `OrderedSet recipe <https://github.com/ActiveState/code/tree/master/recipes/Python/576694_OrderedSet/recipe-576694.py>`_ for an
312312
example built on :class:`MutableSet`.
313313

314314
* For more about ABCs, see the :mod:`abc` module and :pep:`3119`.

Doc/library/collections.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ The class can be used to simulate nested scopes and is useful in templating.
135135
:attr:`~collections.ChainMap.parents` property.
136136

137137
* The `Nested Contexts recipe
138-
<https://code.activestate.com/recipes/577434/>`_ has options to control
138+
<https://github.com/ActiveState/code/tree/master/recipes/Python/577434_Nested_contexts__chamapping/recipe-577434.py>`_ has options to control
139139
whether writes and other mutations apply only to the first mapping or to
140140
any mapping in the chain.
141141

142142
* A `greatly simplified read-only version of Chainmap
143-
<https://code.activestate.com/recipes/305268/>`_.
143+
<https://github.com/ActiveState/code/tree/master/recipes/Python/305268_Chained_map_lookups/recipe-305268.py>`_.
144144

145145

146146
:class:`ChainMap` Examples and Recipes

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/difflib.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
--------------
1919

2020
This module provides classes and functions for comparing sequences. It
21-
can be used for example, for comparing files, and can produce difference
22-
information in various formats, including HTML and context and unified
21+
can be used for example, for comparing files, and can produce information
22+
about file differences in various formats, including HTML and context and unified
2323
diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
2424

2525

@@ -633,7 +633,7 @@ If you want to know how to change the first sequence into the second, use
633633
work.
634634

635635
* `Simple version control recipe
636-
<https://code.activestate.com/recipes/576729/>`_ for a small application
636+
<https://github.com/ActiveState/code/tree/master/recipes/Python/576729_Simple_Version_Control/recipe-576729.py>`_ for a small application
637637
built with :class:`SequenceMatcher`.
638638

639639

Doc/library/enum.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ An enumeration is a set of symbolic names (members) bound to unique,
1919
constant values. Within an enumeration, the members can be compared
2020
by identity, and the enumeration itself can be iterated over.
2121

22+
.. note:: Case of Enum Members
23+
24+
Because Enums are used to represent constants we recommend using
25+
UPPER_CASE names for enum members, and will be using that style
26+
in our examples.
27+
2228

2329
Module Contents
2430
---------------
@@ -650,6 +656,13 @@ be combined with them::
650656
>>> Perm.X | 8
651657
<Perm.8|X: 9>
652658

659+
:class:`IntFlag` members can also be iterated over::
660+
661+
>>> list(RW)
662+
[<Perm.R: 4>, <Perm.W: 2>]
663+
664+
.. versionadded:: 3.10
665+
653666

654667
Flag
655668
^^^^
@@ -703,6 +716,14 @@ value::
703716
>>> bool(Color.BLACK)
704717
False
705718

719+
:class:`Flag` members can also be iterated over::
720+
721+
>>> purple = Color.RED | Color.BLUE
722+
>>> list(purple)
723+
[<Color.BLUE: 2>, <Color.RED: 1>]
724+
725+
.. versionadded:: 3.10
726+
706727
.. note::
707728

708729
For the majority of new code, :class:`Enum` and :class:`Flag` are strongly

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/idle.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ in the settings dialog. (To prevent auto popups, set the delay to a
491491
large number of milliseconds, such as 100000000.) For imported module
492492
names or class or function attributes, type '.'.
493493
For filenames in the root directory, type :data:`os.sep` or
494-
data:`os.altsep` immediately after an opening quote. (On Windows,
494+
:data:`os.altsep` immediately after an opening quote. (On Windows,
495495
one can specify a drive first.) Move into subdirectories by typing a
496496
directory name and a separator.
497497

Doc/library/imaplib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ The following utility functions are defined:
143143

144144
.. function:: Int2AP(num)
145145

146-
Converts an integer into a string representation using characters from the set
146+
Converts an integer into a bytes representation using characters from the set
147147
[``A`` .. ``P``].
148148

149149

@@ -197,7 +197,7 @@ you want to avoid having an argument string quoted (eg: the *flags* argument to
197197

198198
Each command returns a tuple: ``(type, [data, ...])`` where *type* is usually
199199
``'OK'`` or ``'NO'``, and *data* is either the text from the command response,
200-
or mandated results from the command. Each *data* is either a string, or a
200+
or mandated results from the command. Each *data* is either a ``bytes``, or a
201201
tuple. If a tuple, then the first part is the header of the response, and the
202202
second part contains the data (ie: 'literal' value).
203203

Doc/library/locale.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ Background, details, hints, tips and caveats
508508
--------------------------------------------
509509

510510
The C standard defines the locale as a program-wide property that may be
511-
relatively expensive to change. On top of that, some implementation are broken
511+
relatively expensive to change. On top of that, some implementations are broken
512512
in such a way that frequent locale changes may cause core dumps. This makes the
513513
locale somewhat painful to use correctly.
514514

0 commit comments

Comments
 (0)