Fix a race condition in SSLProtocol.connection_made() of
asyncio.sslproto: start immediately the handshake instead of using
call_soon(). Previously, data_received() could be called before the
handshake started, causing the handshake to hang or fail.
bpo-31647: Fix write_eof() after close() for SelectorSocketTransport (GH-7149) (#7154)
Fixed bug where calling write_eof() on a _SelectorSocketTransport after
it's already closed raises AttributeError.
(cherry picked from commit 23f587e395e41bd5e116312b036183f42bc4159b)
bpo-33655: Also ignore test_posix_fallocate failures on BSD platforms (GH-7134)
The failure may be due to the use oF ZFS, a case we already ignore
for Solaris-based systems where ZFS is frequently used.
(cherry picked from commit 09c4a7dee2eb39b515e5f499f184257cdbe9cb42)
CtrlZvi [Fri, 25 May 2018 08:03:25 +0000 (01:03 -0700)]
[3.6] bpo-26819: Prevent proactor double read on resume (GH-6921) (#7110)
The proactor event loop has a race condition when reading with
pausing/resuming. `resume_reading()` unconditionally schedules the read
function to read from the current future. If `resume_reading()` was
called before the previously scheduled done callback fires, this results
in two attempts to get the data from the most recent read and an
assertion failure. This commit tracks whether or not `resume_reading`
needs to reschedule the callback to restart the loop, preventing a
second attempt to read the data..
(cherry picked from commit 4151061855b571bf8a7579daa7875b8e243057b9)
bpo-33629: Prevent coredump in test_importlib (GH-7090)
bpo-32374, bpo-33629: Use support.SuppressCrashReport() in
test_bad_traverse() of MultiPhaseExtensionModuleTests to prevent
leaking a core dump file.
(cherry picked from commit 483000e164ec68717d335767b223ae31b4b720cf)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
Serhiy Storchaka [Thu, 24 May 2018 13:05:38 +0000 (16:05 +0300)]
[3.6] bpo-33622: Fix issues with handling errors in the GC. (GH-7078) (GH-7095)
* Fixed a leak when the GC fails to add an object with __del__ into
the gc.garbage list.
* PyGC_Collect() can now be called when an exception is set and
preserves it.
* Fixed an undefined behavior with comparing a dead pointer with NULL.
(cherry picked from commit 301e3cc8a5bc68c5347ab6ac6f83428000d31ab2)
Serhiy Storchaka [Mon, 21 May 2018 12:20:55 +0000 (15:20 +0300)]
[3.6] bpo-33542: Ignore DUID in uuid.get_node on Windows. (GH-6922) (GH-7014)
uuid._ipconfig_getnode did not validate the maximum length of the value,
so long as the value had the same type of formatting as a MAC address.
This let it select DUIDs as MAC addresses. It now requires an exact
length match.
(cherry picked from commit c66c342cb42ab8a88884527ddfe3a5086bc06316)
Andrew Svetlov [Mon, 21 May 2018 10:09:49 +0000 (13:09 +0300)]
[3.6] bpo-33263: Fix FD leak in _SelectorSocketTransport (GH-6450) (#7025)
* bpo-33263 Fix FD leak in _SelectorSocketTransport. (GH-6450)
Under particular circumstances _SelectorSocketTransport can try to add a reader
even the transport is already being closed. This can lead to FD leak and
invalid stated of the following connections. Fixed the SelectorSocketTransport
to add the reader only if the trasport is still active..
(cherry picked from commit a84d0b361a26c05c6fadc6640591ec3feee5bfb5)
Docs: be less specific about python versions (GH-6985)
CPython 3.5 is old now, and we don't bump this version often,
so lets avoid using specific versions.
(cherry picked from commit 9572132ab3c2edddb8087a0112116da866373f79)
Serhiy Storchaka [Sun, 20 May 2018 14:33:55 +0000 (17:33 +0300)]
[3.6] bpo-33584: Fix several minor bugs in asyncio. (GH-7003) (#7006)
* repr() was called for a borrowed link.
* str() was used instead of repr() in formatting one error message.
(cherry picked from commit 6655354afcd116c27486bb5ba1dfa50b369d8d85)
bpo-29706: Test that IDLE colors async/await as keywords. (GH-6846)
Added to the eye-verified htest, not to the unittests.
Also remove some stray leftover comments.
(cherry picked from commit 389a48ede92bf7965889d554d2cd17b50d6e3d86)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
The urllib.robotparser's __str__ representation now includes wildcard
entries and the "Crawl-delay" and "Request-rate" fields.
(cherry picked from commit c3fa1f2b93fa4bf96a8aadc74ee196384cefa31e)
Co-authored-by: Michael Lazar <lazar.michael22@gmail.com>
bpo-32601: Let test_expanduser use the same user if no others found. (GH-5246)
This happens in the NixOS build sandbox, for example, where the only
other user is nobody with home directory /.
(cherry picked from commit 5c0d462689e1a69537eaeba6ab94e3ff3524fc31)
bpo-28055: Fix unaligned accesses in siphash24(). (GH-6123)
The hash implementation casts the input pointer to uint64_t* and directly reads
from this, which may cause unaligned accesses. Use memcpy() instead so this code
will not crash with SIGBUS on sparc.
bpo-33290: Have macOS installer remove "pip" alias (GH-6683) (GH-6685)
Currently, "pip3 install --upgrade pip" unconditionally installs a
"pip" alias even for Python 3. If a user has an existing Python 3.x
installed from a python.org macOS installer and then subsequently
manually updates to a new version of pip, there may now be a stray
"pip" alias in the Python 3.x framework bin directory which can cause
confusion if the user has both a Python 2.7 and 3.x installed;
if the Python 3.x fw bin directory appears early on $PATH, "pip"
might invoke the pip3 for the Python 3.x rather than the pip for
Python 2.7. To try to mitigate this, the macOS installer script
for the ensurepip option will unconditionally remove "pip" from
the 3.x framework bin directory being updated / installed. (The
ambiguity can be avoided by using "pythonx.y -m pip".)
(cherry picked from commit 0dd80709b5dc03756e7f4510761ae60236bb9f6d)
bpo-21474: Update IDLE word/identifier definition from ascii to unicode. (GH-6643)
In text and entry boxes, this affects selection by double-click,
movement left/right by control-left/right, and deletion left/right
by control-BACKSPACE/DEL.
(cherry picked from commit 5ff3a161c8a6b525c5e5b3e36e9c43f5a95bda60)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Antoine Pitrou [Mon, 23 Apr 2018 20:22:49 +0000 (22:22 +0200)]
[3.6] bpo-33329: Fix multiprocessing regression on newer glibcs (GH-6575) (GH-6582)
Starting with glibc 2.27.9000-xxx, sigaddset() can return EINVAL for some
reserved signal numbers between 1 and NSIG. The `range(1, NSIG)` idiom
is commonly used to select all signals for blocking with `pthread_sigmask`.
So we ignore the sigaddset() return value until we expose sigfillset()
to provide a better idiom.
(cherry picked from commit 25038ecfb665bef641abf8cb61afff7505b0e008)
This used to be the case on Python 2. Commit 212b590e118e3650b596917021ed9612a918180b changed the implementation for Python
3, making the `log()` method of LogAdapter call `logger._log()` directly. This
makes nested log adapters not execute their ``process()`` method. This patch
fixes the issue.
Also, now proxying `name`, too, to make `repr()` work with nested log adapters.
bpo-33189: pygettext.py now accepts only literal strings (GH-6364)
as docstrings and translatable strings, and rejects
bytes literals and f-string expressions.
(cherry picked from commit 69524821a87251b7aee966f6e46b3810ff5aaa64)
bpo-33295: Skip test using missing external site (GH-6504) (GH-6511)
`test_urllib2net.OtherNetworkTests.test_sites_no_connection_close`
used `http://www.imdb.com/` but it is moved to https so the test is
not valid anymore. Skip test for the moment to allow CI to proceed.
(cherry picked from commit 36d56ea826caffbeac0fc0c6d90248b80516e33c)