Skip to content

Commit 51a4872

Browse files
author
Jimmy Lai
committed
Merge branch 'master' of https://github.com/python/cpython into asyncio
* 'master' of https://github.com/python/cpython: (32 commits) Conceptually, roots is a set. Also searching it as a set is a tiny bit faster (python#3338) bpo-31343: Include sys/sysmacros.h (python#3318) bpo-30102: Call OPENSSL_add_all_algorithms_noconf (python#3112) Prevent a few make suspicious warnings. (python#3341) Include additional changes to support blurbified NEWS (python#3340) Simplify NEWS entry to prevent suspicious warnings. (python#3339) bpo-31347: _PyObject_FastCall_Prepend: do not call memcpy if args might not be null (python#3329) Revert "bpo-17852: Maintain a list of BufferedWriter objects. Flush them on exit. (python#1908)" (python#3337) bpo-17852: Maintain a list of BufferedWriter objects. Flush them on exit. (python#1908) Fix terminology in comment and add more design rationale. (python#3335) Add comment to explain the implications of not sorting keywords (python#3331) bpo-31170: Update libexpat from 2.2.3 to 2.2.4 (python#3315) bpo-28411: Remove "modules" field from Py_InterpreterState. (python#1638) random_triangular: sqrt() is more accurate than **0.5 (python#3317) Travis: use ccache (python#3307) remove IRIX support (closes bpo-31341) (python#3310) Code clean-up. Remove unnecessary pre-increment before the loop starts. (python#3312) Regen Moduls/clinic/_ssl.c.h (pythonGH-3320) bpo-30502: Fix handling of long oids in ssl. (python#2909) Cache externals, depending on changes to PCbuild (python#3308) ...
2 parents 923312f + 15ce0be commit 51a4872

File tree

587 files changed

+26872
-10421
lines changed

Some content is hidden

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

587 files changed

+26872
-10421
lines changed

.github/CODEOWNERS

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
Python/bootstrap_hash.c @python/crypto-team
2525

2626
# Email and related
27-
**/*mail* @bitdancer
28-
**/*smtp* @bitdancer
29-
**/*mime* @bitdancer
30-
**/*imap* @bitdancer
31-
**/*poplib* @bitdancer
27+
**/*mail* @python/email-team
28+
**/*smtp* @python/email-team
29+
**/*mime* @python/email-team
30+
**/*imap* @python/email-team
31+
**/*poplib* @python/email-team
3232

3333
# subprocess
3434
**/*subprocess* @gpshead
@@ -40,3 +40,12 @@ Python/bootstrap_hash.c @python/crypto-team
4040
# Windows installer packages
4141
/Tools/msi/ @python/windows-team
4242
/Tools/nuget/ @python/windows-team
43+
44+
**/*itertools* @rhettinger
45+
**/*collections* @rhettinger
46+
**/*random* @rhettinger
47+
**/*queue* @rhettinger
48+
**/*bisect* @rhettinger
49+
**/*heapq* @rhettinger
50+
**/*functools* @ncoghlan @rhettinger
51+
**/*decimal* @rhettinger @skrah

.github/appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ branches:
55
- master
66
- /\d\.\d/
77
- buildbot-custom
8+
cache:
9+
- externals -> PCbuild\*
810
build_script:
911
- cmd: PCbuild\build.bat -e
1012
- cmd: PCbuild\win32\python.exe -m test.pythoninfo

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ dist: trusty
33
sudo: false
44
group: beta
55

6-
# To cache doc-building dependencies.
7-
cache: pip
6+
# To cache doc-building dependencies and C compiler output.
7+
cache:
8+
- pip
9+
- ccache
810

911
branches:
1012
only:
@@ -41,7 +43,7 @@ matrix:
4143
- cd Doc
4244
# Sphinx is pinned so that new versions that introduce new warnings won't suddenly cause build failures.
4345
# (Updating the version is fine as long as no warnings are raised by doing so.)
44-
- python -m pip install sphinx~=1.6.1
46+
- python -m pip install sphinx~=1.6.1 blurb
4547
script:
4648
- make check suspicious html SPHINXOPTS="-q -W -j4"
4749
- os: linux

Doc/Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# You can set these variables from the command line.
77
PYTHON = python3
88
SPHINXBUILD = sphinx-build
9+
BLURB = $(PYTHON) -m blurb
910
PAPER =
1011
SOURCES =
1112
DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
@@ -38,6 +39,20 @@ help:
3839
@echo " serve to serve the documentation on the localhost (8000)"
3940

4041
build:
42+
-mkdir -p build
43+
# Look first for a Misc/NEWS file (building from a source release tarball
44+
# or old repo) and use that, otherwise look for a Misc/NEWS.d directory
45+
# (building from a newer repo) and use blurb to generate the NEWS file.
46+
@if [ -f ../Misc/NEWS ] ; then \
47+
echo "Using existing Misc/NEWS file"; \
48+
cp ../Misc/NEWS build/NEWS; \
49+
elif [ -d ../Misc/NEWS.d ]; then \
50+
echo "Building NEWS from Misc/NEWS.d with blurb"; \
51+
$(BLURB) merge -f build/NEWS; \
52+
else \
53+
echo "Neither Misc/NEWS.d nor Misc/NEWS found; cannot build docs"; \
54+
exit 1; \
55+
fi
4156
$(SPHINXBUILD) $(ALLSPHINXOPTS)
4257
@echo
4358

@@ -107,7 +122,7 @@ clean:
107122

108123
venv:
109124
$(PYTHON) -m venv venv
110-
./venv/bin/python3 -m pip install -U Sphinx
125+
./venv/bin/python3 -m pip install -U Sphinx blurb
111126

112127
dist:
113128
rm -rf dist

Doc/c-api/import.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ Importing Modules
204204
Return the dictionary used for the module administration (a.k.a.
205205
``sys.modules``). Note that this is a per-interpreter variable.
206206
207+
.. c:function:: PyObject* PyImport_GetModule(PyObject *name)
208+
209+
Return the already imported module with the given name. If the
210+
module has not been imported yet then returns NULL but does not set
211+
an error. Returns NULL and sets an error if the lookup failed.
212+
213+
.. versionadded:: 3.7
207214
208215
.. c:function:: PyObject* PyImport_GetImporter(PyObject *path)
209216

Doc/distutils/apiref.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,19 +1086,16 @@ other utility module.
10861086

10871087
Return a string that identifies the current platform. This is used mainly to
10881088
distinguish platform-specific build directories and platform-specific built
1089-
distributions. Typically includes the OS name and version and the architecture
1090-
(as supplied by 'os.uname()'), although the exact information included depends
1091-
on the OS; eg. for IRIX the architecture isn't particularly important (IRIX only
1092-
runs on SGI hardware), but for Linux the kernel version isn't particularly
1093-
important.
1089+
distributions. Typically includes the OS name and version and the
1090+
architecture (as supplied by 'os.uname()'), although the exact information
1091+
included depends on the OS; e.g., on Linux, the kernel version isn't
1092+
particularly important.
10941093

10951094
Examples of returned values:
10961095

10971096
* ``linux-i586``
10981097
* ``linux-alpha``
10991098
* ``solaris-2.6-sun4u``
1100-
* ``irix-5.3``
1101-
* ``irix64-6.2``
11021099

11031100
For non-POSIX platforms, currently just returns ``sys.platform``.
11041101

Doc/library/aifc.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ AIFF is Audio Interchange File Format, a format for storing digital audio
1818
samples in a file. AIFF-C is a newer version of the format that includes the
1919
ability to compress the audio data.
2020

21-
.. note::
22-
23-
Some operations may only work under IRIX; these will raise :exc:`ImportError`
24-
when attempting to import the :mod:`cl` module, which is only available on
25-
IRIX.
26-
2721
Audio files have a number of parameters that describe the audio data. The
2822
sampling rate or frame rate is the number of times per second the sound is
2923
sampled. The number of channels indicate if the audio is mono, stereo, or

Doc/library/argparse.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,8 @@ values are:
898898
usage: PROG [-h] foo [foo ...]
899899
PROG: error: too few arguments
900900

901+
.. _`argparse.REMAINDER`:
902+
901903
* ``argparse.REMAINDER``. All the remaining command-line arguments are gathered
902904
into a list. This is commonly useful for command line utilities that dispatch
903905
to other command line utilities::
@@ -1324,8 +1326,11 @@ The parse_args() method
13241326
created and how they are assigned. See the documentation for
13251327
:meth:`add_argument` for details.
13261328

1327-
By default, the argument strings are taken from :data:`sys.argv`, and a new empty
1328-
:class:`Namespace` object is created for the attributes.
1329+
* args_ - List of strings to parse. The default is taken from
1330+
:data:`sys.argv`.
1331+
1332+
* namespace_ - An object to take the attributes. The default is a new empty
1333+
:class:`Namespace` object.
13291334

13301335

13311336
Option value syntax
@@ -1467,6 +1472,7 @@ unambiguous (the prefix matches a unique option)::
14671472
An error is produced for arguments that could produce more than one options.
14681473
This feature can be disabled by setting :ref:`allow_abbrev` to ``False``.
14691474

1475+
.. _args:
14701476

14711477
Beyond ``sys.argv``
14721478
^^^^^^^^^^^^^^^^^^^
@@ -1488,6 +1494,7 @@ interactive prompt::
14881494
>>> parser.parse_args(['1', '2', '3', '4', '--sum'])
14891495
Namespace(accumulate=<built-in function sum>, integers=[1, 2, 3, 4])
14901496

1497+
.. _namespace:
14911498

14921499
The Namespace object
14931500
^^^^^^^^^^^^^^^^^^^^
@@ -2008,7 +2015,12 @@ A partial upgrade path from :mod:`optparse` to :mod:`argparse`:
20082015
* Replace ``(options, args) = parser.parse_args()`` with ``args =
20092016
parser.parse_args()`` and add additional :meth:`ArgumentParser.add_argument`
20102017
calls for the positional arguments. Keep in mind that what was previously
2011-
called ``options``, now in :mod:`argparse` context is called ``args``.
2018+
called ``options``, now in the :mod:`argparse` context is called ``args``.
2019+
2020+
* Replace :meth:`optparse.OptionParser.disable_interspersed_args`
2021+
by setting ``nargs`` of a positional argument to `argparse.REMAINDER`_, or
2022+
use :meth:`~ArgumentParser.parse_known_args` to collect unparsed argument
2023+
strings in a separate list.
20122024

20132025
* Replace callback actions and the ``callback_*`` keyword arguments with
20142026
``type`` or ``action`` arguments.

Doc/library/string.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,21 @@ attributes:
754754
be set in the subclass's class namespace).
755755

756756
* *idpattern* -- This is the regular expression describing the pattern for
757-
non-braced placeholders (the braces will be added automatically as
758-
appropriate). The default value is the regular expression
759-
``[_a-z][_a-z0-9]*``.
757+
non-braced placeholders. The default value is the regular expression
758+
``[_a-z][_a-z0-9]*``. If this is given and *braceidpattern* is ``None``
759+
this pattern will also apply to braced placeholders.
760+
761+
.. versionchanged:: 3.7
762+
*braceidpattern* can be used to define separate patterns used inside and
763+
outside the braces.
764+
765+
* *braceidpattern* -- This is like *idpattern* but describes the pattern for
766+
braced placeholders. Defaults to ``None`` which means to fall back to
767+
*idpattern* (i.e. the same pattern is used both inside and outside braces).
768+
If given, this allows you to define different patterns for braced and
769+
unbraced placeholders.
770+
771+
.. versionadded:: 3.7
760772

761773
* *flags* -- The regular expression flags that will be applied when compiling
762774
the regular expression used for recognizing substitutions. The default value

Doc/library/sysconfig.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,15 @@ Other functions
173173

174174
This is used mainly to distinguish platform-specific build directories and
175175
platform-specific built distributions. Typically includes the OS name and
176-
version and the architecture (as supplied by :func:`os.uname`), although the
177-
exact information included depends on the OS; e.g. for IRIX the architecture
178-
isn't particularly important (IRIX only runs on SGI hardware), but for Linux
179-
the kernel version isn't particularly important.
176+
version and the architecture (as supplied by 'os.uname()'), although the
177+
exact information included depends on the OS; e.g., on Linux, the kernel
178+
version isn't particularly important.
180179

181180
Examples of returned values:
182181

183182
- linux-i586
184183
- linux-alpha (?)
185184
- solaris-2.6-sun4u
186-
- irix-5.3
187-
- irix64-6.2
188185

189186
Windows will return one of:
190187

Doc/make.bat

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ pushd %~dp0
66
set this=%~n0
77

88
call ..\PCBuild\find_python.bat %PYTHON%
9-
if "%SPHINXBUILD%" EQU "" if "%PYTHON%" NEQ "" (
10-
set SPHINXBUILD=%PYTHON%\..\Scripts\sphinx-build.exe
11-
rem Cannot use %SPHINXBUILD% in the same block where we set it
12-
if not exist "%PYTHON%\..\Scripts\sphinx-build.exe" (
9+
if not defined SPHINXBUILD if defined PYTHON (
10+
%PYTHON% -c "import sphinx" > nul 2> nul
11+
if errorlevel 1 (
1312
echo Installing sphinx with %PYTHON%
14-
"%PYTHON%" -m pip install sphinx
13+
%PYTHON% -m pip install sphinx
1514
if errorlevel 1 exit /B
1615
)
16+
set SPHINXBUILD=%PYTHON% -c "import sphinx, sys; sys.argv[0] = 'sphinx-build'; sphinx.main()"
1717
)
1818

19-
if "%PYTHON%" EQU "" set PYTHON=py
20-
if "%SPHINXBUILD%" EQU "" set SPHINXBUILD=sphinx-build
19+
if not defined PYTHON set PYTHON=py
20+
if not defined SPHINXBUILD set SPHINXBUILD=sphinx-build
2121

2222
if "%1" NEQ "htmlhelp" goto :skiphhcsearch
2323
if exist "%HTMLHELP%" goto :skiphhcsearch
@@ -99,7 +99,7 @@ goto end
9999
if NOT "%PAPER%" == "" (
100100
set SPHINXOPTS=-D latex_elements.papersize=%PAPER% %SPHINXOPTS%
101101
)
102-
cmd /C %SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . %BUILDDIR%\%*
102+
cmd /C "%SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . %BUILDDIR%\%*"
103103

104104
if "%1" EQU "htmlhelp" (
105105
cmd /C "%HTMLHELP%" build\htmlhelp\python%DISTVERSION:.=%.hhp

Doc/tools/susp-ignored.csv

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,8 @@ whatsnew/3.5,,:warning,'WARNING:root:warning\n'
325325
whatsnew/3.5,,::,>>> addr6 = ipaddress.IPv6Address('::1')
326326
whatsnew/3.5,,:root,ERROR:root:exception
327327
whatsnew/3.5,,:exception,ERROR:root:exception
328-
whatsnew/changelog,,:version,import sys; I = version[:version.index(' ')]
328+
whatsnew/changelog,,`,'`'
329329
whatsnew/changelog,,:end,str[start:end]
330330
library/binascii,,`,'`'
331331
library/uu,,`,'`'
332332
whatsnew/3.7,,`,'`'
333-
whatsnew/changelog,,`,'`'

Doc/whatsnew/3.7.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ New function :func:`os.register_at_fork` allows registering Python callbacks
223223
to be executed on a process fork. (Contributed by Antoine Pitrou in
224224
:issue:`16500`.)
225225

226+
string
227+
------
228+
229+
:class:`string.Template` now lets you to optionally modify the regular
230+
expression pattern for braced placeholders and non-braced placeholders
231+
separately. (Contributed by Barry Warsaw in :issue:`1198569`.)
232+
226233
unittest.mock
227234
-------------
228235

@@ -449,6 +456,9 @@ Changes in the Python API
449456
and module are affected by this change. (Contributed by INADA Naoki and
450457
Eugene Toder in :issue:`29463`.)
451458

459+
* ``PyInterpreterState`` no longer has a ``modules`` field. Instead use
460+
``sys.modules``.
461+
452462
* The *mode* argument of :func:`os.makedirs` no longer affects the file
453463
permission bits of newly-created intermediate-level directories.
454464
To set their file permission bits you can set the umask before invoking

Doc/whatsnew/changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
Changelog
55
+++++++++
66

7-
.. miscnews:: ../../Misc/NEWS
7+
.. miscnews:: ../build/NEWS

Include/import.h

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,25 @@ PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
3838
);
3939
#endif
4040
PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
41+
#ifndef Py_LIMITED_API
42+
PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
43+
#endif
44+
PyAPI_FUNC(PyObject *) PyImport_GetModule(PyObject *name);
45+
#ifndef Py_LIMITED_API
46+
PyAPI_FUNC(PyObject *) _PyImport_GetModule(PyObject *name);
47+
PyAPI_FUNC(PyObject *) _PyImport_GetModuleWithError(PyObject *name);
48+
PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(struct _Py_Identifier *name);
49+
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
50+
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
51+
#endif
4152
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
4253
PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
4354
PyObject *name
4455
);
4556
#endif
57+
#ifndef Py_LIMITED_API
58+
PyAPI_FUNC(PyObject *) _PyImport_AddModuleObject(PyObject *, PyObject *);
59+
#endif
4660
PyAPI_FUNC(PyObject *) PyImport_AddModule(
4761
const char *name /* UTF-8 encoded string */
4862
);
@@ -97,14 +111,19 @@ PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
97111
PyAPI_FUNC(void) _PyImport_ReInitLock(void);
98112

99113
PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
100-
const char *name /* UTF-8 encoded string */
114+
const char *name, /* UTF-8 encoded string */
115+
PyObject *modules
101116
);
102117
PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *);
118+
PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObjectEx(PyObject *, PyObject *,
119+
PyObject *);
103120
PyAPI_FUNC(int) _PyImport_FixupBuiltin(
104121
PyObject *mod,
105-
const char *name /* UTF-8 encoded string */
122+
const char *name, /* UTF-8 encoded string */
123+
PyObject *modules
106124
);
107-
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);
125+
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *,
126+
PyObject *, PyObject *);
108127

109128
struct _inittab {
110129
const char *name; /* ASCII encoded string */

Include/modsupport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);
191191

192192
PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
193193
int apiver);
194+
#ifndef Py_LIMITED_API
195+
PyAPI_FUNC(PyObject *) _PyModule_CreateInitialized(struct PyModuleDef*,
196+
int apiver);
197+
#endif
194198

195199
#ifdef Py_LIMITED_API
196200
#define PyModule_Create(module) \

Include/pystate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ typedef struct _is {
5252

5353
int64_t id;
5454

55-
PyObject *modules;
5655
PyObject *modules_by_index;
5756
PyObject *sysdict;
5857
PyObject *builtins;

0 commit comments

Comments
 (0)