Skip to content

Commit 69b13f7

Browse files
committed
Merge remote-tracking branch 'upstream/master' into bpo-30555-windowsconsoleio-fd-redirection
2 parents 07a979f + d5ed47d commit 69b13f7

File tree

179 files changed

+5499
-4129
lines changed

Some content is hidden

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

179 files changed

+5499
-4129
lines changed

.github/appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ build_script:
99
- cmd: PCbuild\build.bat -e
1010
test_script:
1111
- cmd: PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 --fail-env-changed -j0
12+
environment:
13+
HOST_PYTHON: C:\Python36\python.exe
1214

1315
# Only trigger AppVeyor if actual code or its configuration changes
1416
only_commits:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ PCbuild/*.VC.opendb
6060
PCbuild/.vs/
6161
PCbuild/amd64/
6262
PCbuild/obj/
63-
PCBuild/win32/
63+
PCbuild/win32/
6464
.purify
6565
Parser/pgen
6666
Parser/pgen.exe

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ matrix:
6262
./venv/bin/python -m pip install -U coverage
6363
script:
6464
# Skip tests that re-run the entire test suite.
65-
- ./venv/bin/python -m coverage run --pylib -m test -uall,-cpu,-tzdata -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_multiprocessing_spawn
65+
- ./venv/bin/python -m coverage run --pylib -m test -uall,-cpu -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_multiprocessing_spawn
6666
after_script: # Probably should be after_success once test suite updated to run under coverage.py.
6767
# Make the `coverage` command available to Codecov w/ a version of Python that can parse all source files.
6868
- source ./venv/bin/activate
@@ -95,7 +95,7 @@ script:
9595
# Only run on Linux as the check only needs to be run once.
9696
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./python Tools/scripts/patchcheck.py --travis $TRAVIS_PULL_REQUEST; fi
9797
# `-r -w` implicitly provided through `make buildbottest`.
98-
- make buildbottest TESTOPTS="-j4 -uall,-cpu,-tzdata"
98+
- make buildbottest TESTOPTS="-j4 -uall,-cpu"
9999

100100
notifications:
101101
email: false

Doc/howto/curses.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ and full support for mouse and keyboard input.
6565
The Python curses module
6666
------------------------
6767

68-
Thy Python module is a fairly simple wrapper over the C functions provided by
68+
The Python module is a fairly simple wrapper over the C functions provided by
6969
curses; if you're already familiar with curses programming in C, it's really
7070
easy to transfer that knowledge to Python. The biggest difference is that the
7171
Python interface makes things simpler by merging different C functions such as

Doc/installing/index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,17 @@ On such systems, it is often better to use a virtual environment or a
211211
per-user installation when installing packages with ``pip``.
212212

213213

214+
Pip not installed
215+
-----------------
216+
217+
It is possible that ``pip`` does not get installed by default. One potential fix is::
218+
219+
python -m ensurepip --default-pip
220+
221+
There are also additional resources for `installing pip.
222+
<https://packaging.python.org/tutorials/installing-packages/#install-pip-setuptools-and-wheel>`__
223+
224+
214225
Installing binary extensions
215226
----------------------------
216227

Doc/library/2to3.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ and off individually. They are described here in more detail.
288288
289289
Fixes duplicate types in the second argument of :func:`isinstance`. For
290290
example, ``isinstance(x, (int, int))`` is converted to ``isinstance(x,
291-
(int))``.
291+
int)`` and ``isinstance(x, (int, float, int))`` is converted to
292+
``isinstance(x, (int, float))``.
292293
293294
.. 2to3fixer:: itertools_imports
294295

Doc/library/asyncio-eventloop.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
Base Event Loop
66
===============
77

8+
**Source code:** :source:`Lib/asyncio/events.py`
9+
810
The event loop is the central execution device provided by :mod:`asyncio`.
911
It provides multiple facilities, including:
1012

Doc/library/asyncio-eventloops.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Event loops
44
===========
55

6+
**Source code:** :source:`Lib/asyncio/events.py`
7+
68
Event loop functions
79
--------------------
810

Doc/library/asyncio-protocol.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
.. currentmodule:: asyncio
22

3-
++++++++++++++++++++++++++++++++++++++++++++++
4-
Transports and protocols (callback based API)
5-
++++++++++++++++++++++++++++++++++++++++++++++
3+
+++++++++++++++++++++++++++++++++++++++++++++
4+
Transports and protocols (callback based API)
5+
+++++++++++++++++++++++++++++++++++++++++++++
6+
7+
**Source code:** :source:`Lib/asyncio/transports.py`
8+
9+
**Source code:** :source:`Lib/asyncio/protocols.py`
610

711
.. _asyncio-transport:
812

Doc/library/asyncio-queue.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Queues
44
======
55

6+
**Source code:** :source:`Lib/asyncio/queues.py`
7+
68
Queues:
79

810
* :class:`Queue`

Doc/library/asyncio-stream.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
Streams (coroutine based API)
77
+++++++++++++++++++++++++++++
88

9+
**Source code:** :source:`Lib/asyncio/streams.py`
10+
911
Stream functions
1012
================
1113

Doc/library/asyncio-subprocess.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
Subprocess
66
==========
77

8+
**Source code:** :source:`Lib/asyncio/subprocess.py`
9+
810
Windows event loop
911
------------------
1012

Doc/library/asyncio-sync.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Synchronization primitives
55
==========================
66

7+
**Source code:** :source:`Lib/asyncio/locks.py`
8+
79
Locks:
810

911
* :class:`Lock`

Doc/library/asyncio-task.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Tasks and coroutines
44
====================
55

6+
**Source code:** :source:`Lib/asyncio/tasks.py`
7+
8+
**Source code:** :source:`Lib/asyncio/coroutines.py`
9+
610
.. _coroutine:
711

812
Coroutines

Doc/library/datetime.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,12 @@ Supported operations:
287287
| | ``[D day[s], ][H]H:MM:SS[.UUUUUU]``, where D |
288288
| | is negative for negative ``t``. (5) |
289289
+--------------------------------+-----------------------------------------------+
290-
| ``repr(t)`` | Returns a string in the form |
291-
| | ``datetime.timedelta(D[, S[, U]])``, where D |
292-
| | is negative for negative ``t``. (5) |
290+
| ``repr(t)`` | Returns a string representation of the |
291+
| | :class:`timedelta` object as a constructor |
292+
| | call with canonical attribute values. |
293293
+--------------------------------+-----------------------------------------------+
294294

295+
295296
Notes:
296297

297298
(1)

Doc/library/functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ are always available. They are listed here in alphabetical order.
13611361
:func:`itertools.islice` for an alternate version that returns an iterator.
13621362

13631363

1364-
.. function:: sorted(iterable[, key][, reverse])
1364+
.. function:: sorted(iterable, *, key=None, reverse=False)
13651365

13661366
Return a new sorted list from the items in *iterable*.
13671367

Doc/library/multiprocessing.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,12 @@ The :mod:`multiprocessing` package mostly replicates the API of the
598598
acquired a lock or semaphore etc. then terminating it is liable to
599599
cause other processes to deadlock.
600600

601+
.. method:: kill()
602+
603+
Same as :meth:`terminate()` but using the ``SIGKILL`` signal on Unix.
604+
605+
.. versionadded:: 3.7
606+
601607
.. method:: close()
602608

603609
Close the :class:`Process` object, releasing all resources associated

Doc/library/stdtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ application).
11611161
:ref:`mutable <typesseq-mutable>` sequence operations. Lists also provide the
11621162
following additional method:
11631163

1164-
.. method:: list.sort(*, key=None, reverse=None)
1164+
.. method:: list.sort(*, key=None, reverse=False)
11651165

11661166
This method sorts the list in place, using only ``<`` comparisons
11671167
between items. Exceptions are not suppressed - if any comparison operations

Doc/library/turtle.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2367,7 +2367,7 @@ The demo scripts are:
23672367
| wikipedia | a pattern from the wikipedia | :func:`clone`, |
23682368
| | article on turtle graphics | :func:`undo` |
23692369
+----------------+------------------------------+-----------------------+
2370-
| yingyang | another elementary example | :func:`circle` |
2370+
| yinyang | another elementary example | :func:`circle` |
23712371
+----------------+------------------------------+-----------------------+
23722372

23732373
Have fun!

Doc/make.bat

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@ pushd %~dp0
55

66
set this=%~n0
77

8-
if "%SPHINXBUILD%" EQU "" set SPHINXBUILD=sphinx-build
8+
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" (
13+
echo Installing sphinx with %PYTHON%
14+
"%PYTHON%" -m pip install sphinx
15+
if errorlevel 1 exit /B
16+
)
17+
)
18+
919
if "%PYTHON%" EQU "" set PYTHON=py
20+
if "%SPHINXBUILD%" EQU "" set SPHINXBUILD=sphinx-build
1021

1122
if "%1" NEQ "htmlhelp" goto :skiphhcsearch
1223
if exist "%HTMLHELP%" goto :skiphhcsearch

Doc/tools/extensions/pyspecific.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from time import asctime
1616
from pprint import pformat
1717
from docutils.io import StringOutput
18+
from docutils.parsers.rst import Directive
1819
from docutils.utils import new_document
1920

2021
from docutils import nodes, utils
@@ -23,7 +24,6 @@
2324
from sphinx.builders import Builder
2425
from sphinx.locale import translators
2526
from sphinx.util.nodes import split_explicit_title
26-
from sphinx.util.compat import Directive
2727
from sphinx.writers.html import HTMLTranslator
2828
from sphinx.writers.text import TextWriter
2929
from sphinx.writers.latex import LaTeXTranslator

Doc/tools/templates/download.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ <h1>Download Python {{ release }} Documentation</h1>
1818
<table class="docutils">
1919
<tr><th>Format</th><th>Packed as .zip</th><th>Packed as .tar.bz2</th></tr>
2020
<tr><td>PDF (US-Letter paper size)</td>
21-
<td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-letter.zip">Download</a> (ca. 8 MB)</td>
22-
<td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-letter.tar.bz2">Download</a> (ca. 8 MB)</td>
21+
<td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-letter.zip">Download</a> (ca. 13 MB)</td>
22+
<td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-letter.tar.bz2">Download</a> (ca. 13 MB)</td>
2323
</tr>
2424
<tr><td>PDF (A4 paper size)</td>
25-
<td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-a4.zip">Download</a> (ca. 8 MB)</td>
26-
<td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-a4.tar.bz2">Download</a> (ca. 8 MB)</td>
25+
<td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-a4.zip">Download</a> (ca. 13 MB)</td>
26+
<td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-a4.tar.bz2">Download</a> (ca. 13 MB)</td>
2727
</tr>
2828
<tr><td>HTML</td>
29-
<td><a href="{{ dlbase }}/python-{{ release }}-docs-html.zip">Download</a> (ca. 6 MB)</td>
30-
<td><a href="{{ dlbase }}/python-{{ release }}-docs-html.tar.bz2">Download</a> (ca. 4 MB)</td>
29+
<td><a href="{{ dlbase }}/python-{{ release }}-docs-html.zip">Download</a> (ca. 9 MB)</td>
30+
<td><a href="{{ dlbase }}/python-{{ release }}-docs-html.tar.bz2">Download</a> (ca. 6 MB)</td>
3131
</tr>
3232
<tr><td>Plain Text</td>
33-
<td><a href="{{ dlbase }}/python-{{ release }}-docs-text.zip">Download</a> (ca. 2 MB)</td>
34-
<td><a href="{{ dlbase }}/python-{{ release }}-docs-text.tar.bz2">Download</a> (ca. 1.5 MB)</td>
33+
<td><a href="{{ dlbase }}/python-{{ release }}-docs-text.zip">Download</a> (ca. 3 MB)</td>
34+
<td><a href="{{ dlbase }}/python-{{ release }}-docs-text.tar.bz2">Download</a> (ca. 2 MB)</td>
3535
</tr>
3636
<tr><td>EPUB</td>
37-
<td><a href="{{ dlbase }}/python-{{ release }}-docs.epub">Download</a> (ca. 4.5 MB)</td>
37+
<td><a href="{{ dlbase }}/python-{{ release }}-docs.epub">Download</a> (ca. 5.5 MB)</td>
3838
<td></td>
3939
</tr>
4040
</table>

Doc/tutorial/classes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
Classes
55
*******
66

7+
Classes provide a means of bundling data and functionality together. Creating
8+
a new class creates a new *type* of object, allowing new *instances* of that
9+
type to be made. Each class instance can have attributes attached to it for
10+
maintaining its state. Class instances can also have methods (defined by its
11+
class) for modifying its state.
12+
713
Compared with other programming languages, Python's class mechanism adds classes
814
with a minimum of new syntax and semantics. It is a mixture of the class
915
mechanisms found in C++ and Modula-3. Python classes provide all the standard

Include/fileobject.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
3838
#endif /* Py_LIMITED_API */
3939

4040
/* A routine to check if a file descriptor can be select()-ed. */
41-
#ifdef HAVE_SELECT
42-
#define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
41+
#ifdef _MSC_VER
42+
/* On Windows, any socket fd can be select()-ed, no matter how high */
43+
#define _PyIsSelectable_fd(FD) (1)
4344
#else
44-
#define _PyIsSelectable_fd(FD) (1)
45-
#endif /* HAVE_SELECT */
45+
#define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
46+
#endif
4647

4748
#ifdef __cplusplus
4849
}

Include/modsupport.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,9 @@ PyAPI_FUNC(int) _PyArg_UnpackStack(
6060
...);
6161

6262
PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kwargs);
63-
PyAPI_FUNC(int) _PyArg_NoStackKeywords(const char *funcname, PyObject *kwnames);
6463
PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args);
6564
#define _PyArg_NoKeywords(funcname, kwargs) \
6665
((kwargs) == NULL || _PyArg_NoKeywords((funcname), (kwargs)))
67-
#define _PyArg_NoStackKeywords(funcname, kwnames) \
68-
((kwnames) == NULL || _PyArg_NoStackKeywords((funcname), (kwnames)))
6966
#define _PyArg_NoPositional(funcname, args) \
7067
((args) == NULL || _PyArg_NoPositional((funcname), (args)))
7168

Lib/asyncore.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,9 @@ def getsockopt(self, level, optname, buflen=None):
619619
def close(self):
620620
if self.fd < 0:
621621
return
622-
os.close(self.fd)
622+
fd = self.fd
623623
self.fd = -1
624+
os.close(fd)
624625

625626
def fileno(self):
626627
return self.fd

Lib/datetime.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -454,20 +454,18 @@ def __new__(cls, days=0, seconds=0, microseconds=0,
454454
return self
455455

456456
def __repr__(self):
457-
if self._microseconds:
458-
return "%s.%s(%d, %d, %d)" % (self.__class__.__module__,
459-
self.__class__.__qualname__,
460-
self._days,
461-
self._seconds,
462-
self._microseconds)
457+
args = []
458+
if self._days:
459+
args.append("days=%d" % self._days)
463460
if self._seconds:
464-
return "%s.%s(%d, %d)" % (self.__class__.__module__,
465-
self.__class__.__qualname__,
466-
self._days,
467-
self._seconds)
468-
return "%s.%s(%d)" % (self.__class__.__module__,
461+
args.append("seconds=%d" % self._seconds)
462+
if self._microseconds:
463+
args.append("microseconds=%d" % self._microseconds)
464+
if not args:
465+
args.append('0')
466+
return "%s.%s(%s)" % (self.__class__.__module__,
469467
self.__class__.__qualname__,
470-
self._days)
468+
', '.join(args))
471469

472470
def __str__(self):
473471
mm, ss = divmod(self._seconds, 60)
@@ -2271,7 +2269,8 @@ def _name_from_offset(delta):
22712269
_check_tzinfo_arg, _check_tzname, _check_utc_offset, _cmp, _cmperror,
22722270
_date_class, _days_before_month, _days_before_year, _days_in_month,
22732271
_format_time, _is_leap, _isoweek1monday, _math, _ord2ymd,
2274-
_time, _time_class, _tzinfo_class, _wrap_strftime, _ymd2ord)
2272+
_time, _time_class, _tzinfo_class, _wrap_strftime, _ymd2ord,
2273+
_divide_and_round)
22752274
# XXX Since import * above excludes names that start with _,
22762275
# docstring does not get overwritten. In the future, it may be
22772276
# appropriate to maintain a single module level docstring and

Lib/ftplib.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ def sanitize(self, s):
186186

187187
# Internal: send one line to the server, appending CRLF
188188
def putline(self, line):
189+
if '\r' in line or '\n' in line:
190+
raise ValueError('an illegal newline character should not be contained')
189191
line = line + CRLF
190192
if self.debugging > 1:
191193
print('*put*', self.sanitize(line))

0 commit comments

Comments
 (0)