Skip to content

Commit 3c4af91

Browse files
committed
merge from master
2 parents 7223bc9 + 9db0324 commit 3c4af91

File tree

727 files changed

+21499
-10712
lines changed

Some content is hidden

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

727 files changed

+21499
-10712
lines changed

.azure-pipelines/posix-steps.yml

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ steps:
1010
clean: true
1111
fetchDepth: 5
1212

13+
# Work around a known issue affecting Ubuntu VMs on Pipelines
14+
- script: sudo setfacl -Rb /home/vsts
15+
displayName: 'Workaround ACL issue'
16+
1317
- script: ${{ parameters.sudo_dependencies }} ./.azure-pipelines/posix-deps-${{ parameters.dependencies }}.sh $(openssl_version)
1418
displayName: 'Install dependencies'
1519

.github/CODEOWNERS

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
**/*context* @1st1
1212
**/*genobject* @1st1
1313
**/*hamt* @1st1
14+
Objects/dict* @methane
1415

1516
# Hashing
1617
**/*hashlib* @python/crypto-team
@@ -42,13 +43,22 @@ Python/bootstrap_hash.c @python/crypto-team
4243
**/*imap* @python/email-team
4344
**/*poplib* @python/email-team
4445

46+
# Parser/Pgen
47+
/Parser/pgen/ @pablogsal
48+
49+
# SQLite 3
50+
**/*sqlite* @berkerpeksag
51+
4552
# subprocess
4653
**/*subprocess* @gpshead
4754

4855
# Windows
4956
/PC/ @python/windows-team
5057
/PCbuild/ @python/windows-team
5158

59+
# Urllib
60+
**/*robotparser* @berkerpeksag
61+
5262
# Windows installer packages
5363
/Tools/msi/ @python/windows-team
5464
/Tools/nuget/ @python/windows-team

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: c
2-
dist: trusty
3-
sudo: false
2+
dist: xenial
43
group: beta
54

65
# To cache doc-building dependencies and C compiler output.

Doc/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ check:
174174
$(PYTHON) tools/rstlint.py -i tools -i $(VENVDIR) -i README.rst
175175

176176
serve:
177-
../Tools/scripts/serve.py build/html
177+
$(PYTHON) ../Tools/scripts/serve.py build/html
178178

179179
# Targets for daily automated doc build
180180
# By default, Sphinx only rebuilds pages where the page content has changed.

Doc/bugs.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ [email protected] (behavioral bugs can be sent to [email protected]).
2525
though it may take a while to be processed.
2626

2727
.. seealso::
28-
`Documentation bugs`_ on the Python issue tracker
28+
29+
`Documentation bugs`_
30+
A list of documentation bugs that have been submitted to the Python issue tracker.
31+
32+
`Issue Tracking <https://devguide.python.org/tracker/>`_
33+
Overview of the process involved in reporting an improvement on the tracker.
34+
35+
`Helping with Documentation <https://devguide.python.org/docquality/#helping-with-documentation>`_
36+
Comprehensive guide for individuals that are interested in contributing to Python documentation.
2937

3038
.. _using-the-tracker:
3139

Doc/c-api/init.rst

+30
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The following functions can be safely called before Python is initialized:
3737

3838
* Informative functions:
3939

40+
* :c:func:`Py_IsInitialized`
4041
* :c:func:`PyMem_GetAllocator`
4142
* :c:func:`PyObject_GetArenaAllocator`
4243
* :c:func:`Py_GetBuildInfo`
@@ -855,6 +856,12 @@ code, or when embedding the Python interpreter:
855856
created, the current thread must not have acquired it, otherwise deadlock
856857
ensues.
857858
859+
.. note::
860+
Calling this function from a thread when the runtime is finalizing
861+
will terminate the thread, even if the thread was not created by Python.
862+
You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
863+
check if the interpreter is in process of being finalized before calling
864+
this function to avoid unwanted termination.
858865
859866
.. c:function:: PyThreadState* PyThreadState_Get()
860867
@@ -902,6 +909,12 @@ with sub-interpreters:
902909
When the function returns, the current thread will hold the GIL and be able
903910
to call arbitrary Python code. Failure is a fatal error.
904911
912+
.. note::
913+
Calling this function from a thread when the runtime is finalizing
914+
will terminate the thread, even if the thread was not created by Python.
915+
You can use :c:func:`_Py_IsFinalizing` or :func:`sys.is_finalizing` to
916+
check if the interpreter is in process of being finalized before calling
917+
this function to avoid unwanted termination.
905918
906919
.. c:function:: void PyGILState_Release(PyGILState_STATE)
907920
@@ -1026,6 +1039,18 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
10261039
.. versionadded:: 3.7
10271040
10281041
1042+
.. c:function:: PyObject* PyInterpreterState_GetDict(PyInterpreterState *interp)
1043+
1044+
Return a dictionary in which interpreter-specific data may be stored.
1045+
If this function returns *NULL* then no exception has been raised and
1046+
the caller should assume no interpreter-specific dict is available.
1047+
1048+
This is not a replacement for :c:func:`PyModule_GetState()`, which
1049+
extensions should use to store interpreter-specific state information.
1050+
1051+
.. versionadded:: 3.8
1052+
1053+
10291054
.. c:function:: PyObject* PyThreadState_GetDict()
10301055
10311056
Return a dictionary in which extensions can store thread-specific state
@@ -1382,6 +1407,11 @@ These functions are only intended to be used by advanced debugging tools.
13821407
Return the interpreter state object at the head of the list of all such objects.
13831408
13841409
1410+
.. c:function:: PyInterpreterState* PyInterpreterState_Main()
1411+
1412+
Return the main interpreter state object.
1413+
1414+
13851415
.. c:function:: PyInterpreterState* PyInterpreterState_Next(PyInterpreterState *interp)
13861416
13871417
Return the next interpreter state object after *interp* from the list of all

Doc/c-api/intro.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ Include Files
4848
All function, type and macro definitions needed to use the Python/C API are
4949
included in your code by the following line::
5050

51-
#include "Python.h"
51+
#define PY_SSIZE_T_CLEAN
52+
#include <Python.h>
5253

5354
This implies inclusion of the following standard headers: ``<stdio.h>``,
5455
``<string.h>``, ``<errno.h>``, ``<limits.h>``, ``<assert.h>`` and ``<stdlib.h>``
@@ -60,6 +61,9 @@ This implies inclusion of the following standard headers: ``<stdio.h>``,
6061
headers on some systems, you *must* include :file:`Python.h` before any standard
6162
headers are included.
6263

64+
It is recommended to always define ``PY_SSIZE_T_CLEAN`` before including
65+
``Python.h``. See :ref:`arg-parsing` for a description of this macro.
66+
6367
All user visible names defined by Python.h (except those defined by the included
6468
standard headers) have one of the prefixes ``Py`` or ``_Py``. Names beginning
6569
with ``_Py`` are for internal use by the Python implementation and should not be

Doc/c-api/memory.rst

+9-2
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,9 @@ Customize Memory Allocators
440440
441441
Setup hooks to detect bugs in the Python memory allocator functions.
442442
443-
Newly allocated memory is filled with the byte ``0xCB``, freed memory is
444-
filled with the byte ``0xDB``.
443+
Newly allocated memory is filled with the byte ``0xCD`` (``CLEANBYTE``),
444+
freed memory is filled with the byte ``0xDD`` (``DEADBYTE``). Memory blocks
445+
are surrounded by "forbidden bytes" (``FORBIDDENBYTE``: byte ``0xFD``).
445446
446447
Runtime checks:
447448
@@ -471,6 +472,12 @@ Customize Memory Allocators
471472
if the GIL is held when functions of :c:data:`PYMEM_DOMAIN_OBJ` and
472473
:c:data:`PYMEM_DOMAIN_MEM` domains are called.
473474
475+
.. versionchanged:: 3.8.0
476+
Byte patterns ``0xCB`` (``CLEANBYTE``), ``0xDB`` (``DEADBYTE``) and
477+
``0xFB`` (``FORBIDDENBYTE``) have been replaced with ``0xCD``, ``0xDD``
478+
and ``0xFD`` to use the same values than Windows CRT debug ``malloc()``
479+
and ``free()``.
480+
474481
475482
.. _pymalloc:
476483

Doc/c-api/typeobj.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,8 @@ and :c:type:`PyType_Type` effectively act as defaults.)
15581558
:c:member:`~PyTypeObject.tp_init` function is called; if :c:member:`~PyTypeObject.tp_new` returns an instance of a
15591559
subtype of the original type, the subtype's :c:member:`~PyTypeObject.tp_init` is called.
15601560

1561+
Returns ``0`` on success, ``-1`` and sets an exception on error.
1562+
15611563
**Inheritance:**
15621564

15631565
This field is inherited by subtypes.
@@ -2050,7 +2052,7 @@ Sequence Object Structures
20502052
signature. It should modify its first operand, and return it. This slot
20512053
may be left to *NULL*, in this case :c:func:`!PySequence_InPlaceConcat`
20522054
will fall back to :c:func:`PySequence_Concat`. It is also used by the
2053-
augmented assignment ``+=``, after trying numeric inplace addition
2055+
augmented assignment ``+=``, after trying numeric in-place addition
20542056
via the :c:member:`~PyNumberMethods.nb_inplace_add` slot.
20552057

20562058
.. c:member:: ssizeargfunc PySequenceMethods.sq_inplace_repeat
@@ -2059,7 +2061,7 @@ Sequence Object Structures
20592061
signature. It should modify its first operand, and return it. This slot
20602062
may be left to *NULL*, in this case :c:func:`!PySequence_InPlaceRepeat`
20612063
will fall back to :c:func:`PySequence_Repeat`. It is also used by the
2062-
augmented assignment ``*=``, after trying numeric inplace multiplication
2064+
augmented assignment ``*=``, after trying numeric in-place multiplication
20632065
via the :c:member:`~PyNumberMethods.nb_inplace_multiply` slot.
20642066

20652067

Doc/c-api/veryhigh.rst

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ the same library that the Python runtime is using.
109109
(:func:`sys.getfilesystemencoding`). If *closeit* is true, the file is
110110
closed before PyRun_SimpleFileExFlags returns.
111111
112+
.. note::
113+
On Windows, *fp* should be opened as binary mode (e.g. ``fopen(filename, "rb")``.
114+
Otherwise, Python may not handle script file with LF line ending correctly.
115+
112116
113117
.. c:function:: int PyRun_InteractiveOne(FILE *fp, const char *filename)
114118

Doc/distutils/apiref.rst

+4
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ the full reference.
277277
| | simply skip the extension. | |
278278
+------------------------+--------------------------------+---------------------------+
279279

280+
.. versionchanged:: 3.8
281+
282+
On Unix, C extensions are no longer linked to libpython.
283+
280284

281285
.. class:: Distribution
282286

Doc/extending/building.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ that distutils gets the invocations right.
145145
Distributing your extension modules
146146
===================================
147147

148-
When an extension has been successfully build, there are three ways to use it.
148+
When an extension has been successfully built, there are three ways to use it.
149149

150150
End-users will typically want to install the module, they do so by running ::
151151

@@ -158,7 +158,7 @@ Module maintainers should produce source packages; to do so, they run ::
158158
In some cases, additional files need to be included in a source distribution;
159159
this is done through a :file:`MANIFEST.in` file; see :ref:`manifest` for details.
160160

161-
If the source distribution has been build successfully, maintainers can also
161+
If the source distribution has been built successfully, maintainers can also
162162
create binary distributions. Depending on the platform, one of the following
163163
commands can be used to do so. ::
164164

Doc/extending/embedding.rst

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ interface. This interface is intended to execute a Python script without needing
5353
to interact with the application directly. This can for example be used to
5454
perform some operation on a file. ::
5555

56+
#define PY_SSIZE_T_CLEAN
5657
#include <Python.h>
5758

5859
int

Doc/extending/extending.rst

+8-3
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ called ``spam``, the C file containing its implementation is called
5555
:file:`spammodule.c`; if the module name is very long, like ``spammify``, the
5656
module name can be just :file:`spammify.c`.)
5757

58-
The first line of our file can be::
58+
The first two lines of our file can be::
5959

60+
#define PY_SSIZE_T_CLEAN
6061
#include <Python.h>
6162

6263
which pulls in the Python API (you can add a comment describing the purpose of
@@ -68,6 +69,9 @@ the module and a copyright notice if you like).
6869
headers on some systems, you *must* include :file:`Python.h` before any standard
6970
headers are included.
7071

72+
It is recommended to always define ``PY_SSIZE_T_CLEAN`` before including
73+
``Python.h``. See :ref:`parsetuple` for a description of this macro.
74+
7175
All user-visible symbols defined by :file:`Python.h` have a prefix of ``Py`` or
7276
``PY``, except those defined in standard header files. For convenience, and
7377
since they are used extensively by the Python interpreter, ``"Python.h"``
@@ -729,7 +733,8 @@ it returns false and raises an appropriate exception.
729733
Here is an example module which uses keywords, based on an example by Geoff
730734
Philbrick ([email protected])::
731735

732-
#include "Python.h"
736+
#define PY_SSIZE_T_CLEAN /* Make "s#" use Py_ssize_t rather than int. */
737+
#include <Python.h>
733738

734739
static PyObject *
735740
keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds)
@@ -1228,7 +1233,7 @@ The function :c:func:`spam_system` is modified in a trivial way::
12281233

12291234
In the beginning of the module, right after the line ::
12301235

1231-
#include "Python.h"
1236+
#include <Python.h>
12321237

12331238
two more lines must be added::
12341239

Doc/extending/newtypes_tutorial.rst

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ The second bit is the definition of the type object. ::
9292
.tp_doc = "Custom objects",
9393
.tp_basicsize = sizeof(CustomObject),
9494
.tp_itemsize = 0,
95+
.tp_flags = Py_TPFLAGS_DEFAULT,
9596
.tp_new = PyType_GenericNew,
9697
};
9798

Doc/faq/extending.rst

+2
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ solution then is to call :c:func:`PyParser_ParseString` and test for ``e.error``
280280
equal to ``E_EOF``, which means the input is incomplete. Here's a sample code
281281
fragment, untested, inspired by code from Alex Farber::
282282

283+
#define PY_SSIZE_T_CLEAN
283284
#include <Python.h>
284285
#include <node.h>
285286
#include <errcode.h>
@@ -318,6 +319,7 @@ complete example using the GNU readline library (you may want to ignore
318319
#include <stdio.h>
319320
#include <readline.h>
320321

322+
#define PY_SSIZE_T_CLEAN
321323
#include <Python.h>
322324
#include <object.h>
323325
#include <compile.h>

Doc/faq/general.rst

+4-8
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,10 @@ guaranteed that interfaces will remain the same throughout a series of bugfix
306306
releases.
307307

308308
The latest stable releases can always be found on the `Python download page
309-
<https://www.python.org/downloads/>`_. There are two production-ready version
310-
of Python: 2.x and 3.x, but the recommended one at this times is Python 3.x.
311-
Although Python 2.x is still widely used, `it will not be
312-
maintained after January 1, 2020 <https://www.python.org/dev/peps/pep-0373/>`_.
313-
Python 2.x was known for having more third-party libraries available, however,
314-
by the time of this writing, most of the widely used libraries support Python 3.x,
315-
and some are even dropping the Python 2.x support.
316-
309+
<https://www.python.org/downloads/>`_. There are two production-ready versions
310+
of Python: 2.x and 3.x. The recommended version is 3.x, which is supported by
311+
most widely used libraries. Although 2.x is still widely used, `it will not
312+
be maintained after January 1, 2020 <https://www.python.org/dev/peps/pep-0373/>`_.
317313

318314
How many people are using Python?
319315
---------------------------------

Doc/faq/windows.rst

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Python on Windows FAQ
1515
.. XXX need review for Python 3.
1616
XXX need review for Windows Vista/Seven?
1717
18+
.. _faq-run-program-under-windows:
19+
1820

1921
How do I run a Python program under Windows?
2022
--------------------------------------------

Doc/glossary.rst

+7
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,11 @@ Glossary
663663
:term:`finder`. See :pep:`302` for details and
664664
:class:`importlib.abc.Loader` for an :term:`abstract base class`.
665665

666+
magic method
667+
.. index:: pair: magic; method
668+
669+
An informal synonym for :term:`special method`.
670+
666671
mapping
667672
A container object that supports arbitrary key lookups and implements the
668673
methods specified in the :class:`~collections.abc.Mapping` or
@@ -1004,6 +1009,8 @@ Glossary
10041009
(subscript) notation uses :class:`slice` objects internally.
10051010

10061011
special method
1012+
.. index:: pair: special; method
1013+
10071014
A method that is called implicitly by Python to execute a certain
10081015
operation on a type, such as addition. Such methods have names starting
10091016
and ending with double underscores. Special methods are documented in

Doc/howto/descriptor.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ calls are unexciting::
372372
... print(x)
373373
... f = staticmethod(f)
374374
...
375-
>>> print(E.f(3))
375+
>>> E.f(3)
376376
3
377-
>>> print(E().f(3))
377+
>>> E().f(3)
378378
3
379379

380380
Using the non-data descriptor protocol, a pure Python version of

Doc/howto/regex.rst

+7
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,13 @@ given numbers, so you can retrieve information about a group in two ways::
942942
>>> m.group(1)
943943
'Lots'
944944

945+
Additionally, you can retrieve named groups as a dictionary with
946+
:meth:`~re.Match.groupdict`::
947+
948+
>>> m = re.match(r'(?P<first>\w+) (?P<last>\w+)', 'Jane Doe')
949+
>>> m.groupdict()
950+
{'first': 'Jane', 'last': 'Doe'}
951+
945952
Named groups are handy because they let you use easily-remembered names, instead
946953
of having to remember numbers. Here's an example RE from the :mod:`imaplib`
947954
module::

0 commit comments

Comments
 (0)