Mariatta [Sat, 10 Jun 2017 03:36:28 +0000 (20:36 -0700)]
bpo-30266: support "= None" pattern in AbstractContextManager (GH-1448) (GH-2054)
contextlib.AbstractContextManager now supports anti-registration
by setting __enter__ = None or __exit__ = None, following the pattern
introduced in bpo-25958..
(cherry picked from commit 57161aac5eb9bcb0b43e551a1937ff0a84c1ec52)
Yury Selivanov [Fri, 9 Jun 2017 21:06:39 +0000 (17:06 -0400)]
[3.6] bpo-30039: Don't run signal handlers while resuming a yield from stack (GH-1081) (#1640)
If we have a chain of generators/coroutines that are 'yield from'ing
each other, then resuming the stack works like:
- call send() on the outermost generator
- this enters _PyEval_EvalFrameDefault, which re-executes the
YIELD_FROM opcode
- which calls send() on the next generator
- which enters _PyEval_EvalFrameDefault, which re-executes the
YIELD_FROM opcode
- ...etc.
However, every time we enter _PyEval_EvalFrameDefault, the first thing
we do is to check for pending signals, and if there are any then we
run the signal handler. And if it raises an exception, then we
immediately propagate that exception *instead* of starting to execute
bytecode. This means that e.g. a SIGINT at the wrong moment can "break
the chain" – it can be raised in the middle of our yield from chain,
with the bottom part of the stack abandoned for the garbage collector.
The fix is pretty simple: there's already a special case in
_PyEval_EvalFrameEx where it skips running signal handlers if the next
opcode is SETUP_FINALLY. (I don't see how this accomplishes anything
useful, but that's another story.) If we extend this check to also
skip running signal handlers when the next opcode is YIELD_FROM, then
that closes the hole – now the exception can only be raised at the
innermost stack frame.
This shouldn't have any performance implications, because the opcode
check happens inside the "slow path" after we've already determined
that there's a pending signal or something similar for us to process;
the vast majority of the time this isn't true and the new check
doesn't run at all..
(cherry picked from commit ab4413a7e9bda95b6fcd517073e2a51dafaa1624)
* RFC 1750 has been been obsoleted by RFC 4086.
* RFC 3280 has been obsoleted by RFC 5280.
* RFC 4366 has been obsoleted by RFC 6066.
(cherry picked from commit 63c2c8ac17750ba2be2cfc4e339cae1f4edee54f)
Victor Stinner [Fri, 9 Jun 2017 11:24:53 +0000 (13:24 +0200)]
bpo-30524: Fix _PyStack_UnpackDict() (#1886)
* bpo-29259: Remove unused func parameter of _PyStack_UnpackDict()
* bpo-29286: Change _PyStack_UnpackDict() prototype to be able to
notify of failure when args is NULL. _PyStack_UnpackDict() now
returns -1 on error.
[3.6] bpo-30529: Fix errors for invalid whitespaces in f-string subexpressions. (GH-1888) (#2013)
'invalid character in identifier' now is raised instead of
'f-string: empty expression not allowed' if a subexpression contains
only whitespaces and they are not accepted by Python parser.
(cherry picked from commit 2e9cd58)
On Windows, subprocess.Popen.communicate() now also ignore EINVAL
on stdin.write() if the child process is still running but closed the
pipe.
(cherry picked from commit d52aa31378ae43e044a300edfe8285954c167216)
Victor Stinner [Thu, 8 Jun 2017 21:13:12 +0000 (23:13 +0200)]
bpo-30601: Fix a refleak in WindowsConsoleIO (#2003) (#2008)
Fix a reference leak in _io._WindowsConsoleIO: PyUnicode_FSDecoder()
always initialize decodedname when it succeed and it doesn't clear
input decodedname object.
(cherry picked from commit 29adc13bd797d9c9e7fcb893a7c49ce7f7ad388c)
[3.6] bpo-30594: Fixed refcounting in newPySSLSocket (GH-1992) (#1994)
If pass a server_hostname= that fails IDNA decoding to SSLContext.wrap_socket or SSLContext.wrap_bio, then the SSLContext object had a spurious Py_DECREF called on it, eventually leading to segfaults.
(cherry picked from commit 65ece7ca2366308fa91a39a8dfa255e6bdce3cca)
Nate [Wed, 7 Jun 2017 04:21:34 +0000 (21:21 -0700)]
[3.6] bpo-29822: make inspect.isabstract() work during __init_subclass__ (#1979)
At the time when an abstract base class' __init_subclass__ runs,
ABCMeta.__new__ has not yet finished running, so in the presence of
__init_subclass__, inspect.isabstract() can no longer depend only on
TPFLAGS_IS_ABSTRACT.
(cherry picked from commit fcfe80ec2592fed8b3941c79056a8737abef7d3b)
Nate [Wed, 7 Jun 2017 00:31:03 +0000 (17:31 -0700)]
bpo-29581: bpo-29581: Make ABCMeta.__new__ pass **kwargs to type.__new__ (GH-527) (GH-1282)
Many metaclasses in the standard library don't play nice with
__init_subclass__. This bug makes ABCMeta in particular with
__init_subclass__, which is an 80/20 solution for me personally.
AFAICT, a general solution to this problem requires updating all
metaclasses in the standard library to make sure they pass **kwargs to
type.__new__, whereas this PR only fixes ABCMeta. For context, see
https://bugs.python.org/issue29581.
* added a test combining ABCMeta and __init_subclass__
* Added NEWS item
* [3.6] bpo-29581: Make ABCMeta.__new__ pass **kwargs to type.__new__ (GH-527)
Many metaclasses in the standard library don't play nice with
__init_subclass__. This bug makes ABCMeta in particular with
__init_subclass__, which is an 80/20 solution for me personally.
AFAICT, a general solution to this problem requires updating all
metaclasses in the standard library to make sure they pass **kwargs to
type.__new__, whereas this PR only fixes ABCMeta. For context, see
https://bugs.python.org/issue29581.
Clarify that `two-pass` buffer can only be dumped once, and it prints out all text sent to it during all processing, even from Clinic blocks *after* the dumping point.
The patch for bpo-30052 changed the preferred link target
for :func:`bytes` and :func`bytearray` references to be the
respective type definitions rather than the corresponding
builtin function entries.
This patch changes the daily documentation builds to disable
the output caching in Sphinx, in order to ensure that
cross-reference changes like this one are reliably picked
up and applied automatically after merging.
(cherry picked from commit 7a82f9c2b94d31c8f4cc8bb8e3151765d8b148d7)
Mariatta [Mon, 5 Jun 2017 03:06:48 +0000 (20:06 -0700)]
bpo-30530: Update Descriptor How To Documentation (GH-1845) (GH-1953)
Update the code example in Functions and Methods section
Remove objtype argument in MethodType
(cherry picked from commit 1bced56567335745f91676192fc39c06aab30da9)
Brett Cannon [Sat, 3 Jun 2017 17:33:53 +0000 (10:33 -0700)]
[3.6] Turn on macOS builds for Travis (GH-1846) (#1929)
Initially the macOS builds are allowed to fail until such time that they can be determined to be stable and not add an unacceptable amount of time to the overall Travis-passing process.
(cherry picked from commit 21c2dd7cf8414c903f0e83cf1d6b7f02f645f422)
Mariatta [Fri, 2 Jun 2017 04:56:24 +0000 (21:56 -0700)]
bpo-30052: Link `bytes` & `bytearray` to stdtypes not functions (GH-1271) (GH-1915)
Builtin container types have two potential link targets in the docs:
- their entry in the list of builtin callables
- their type documentation
This change brings `bytes` and `bytearray` into line with other
container types by having cross-references default to linking to
their type documentation, rather than their builtin callable entry..
(cherry picked from commit c6db4811f9ea3aeff0e1fafe1c60a22835ef359e)
Mariatta [Thu, 1 Jun 2017 02:49:01 +0000 (19:49 -0700)]
bpo-22702: Clarify documentation of str.join & bytes.join (GH-156) (GH-1897)
The "iterable iterable" phrasing created confusion between the term
reference and the parameter name.
This simplifies the phrasing to just use the parameter name
without linking directly to the term definition.
(cherry picked from commit 08e2f355d04d3cbea5751ce1275306ee3f569b32)
csabella [Tue, 30 May 2017 20:48:22 +0000 (16:48 -0400)]
bpo-30354: Update data model documentation for super() (GH-1561) (GH-1868)
The data model section of the language reference was written well
before the zero-argument form of super() was added.
To avoid giving the impression that they're doing something
unusual, this updates the description of `__new__` and `__init__`
to use the zero-argument form.
Antoine Pitrou [Thu, 25 May 2017 14:57:46 +0000 (16:57 +0200)]
[3.6] bpo-30414: multiprocessing.Queue._feed do not break from main loop on exc (GH-1683) (#1815)
* bpo-30414: multiprocesing.Queue._feed do not break from main loop on exc
Queue background running thread was not handling exceptions correctly.
Any exception occurred inside thread (putting unpickable object) cause
feeder to finish running. After that every message put into queue is
silently ignored.
* bpo-30414: multiprocesing.Queue._feed do not break from main loop on exc
Queue background running thread was not handling exceptions correctly.
Any exception occurred inside thread (putting unpickable object) cause
feeder to finish running. After that every message put into queue is
silently ignored.
(cherry picked from commit bc50f03db4f58c869b78e98468e374d7e61f1227)
Zachary Ware [Wed, 24 May 2017 21:11:01 +0000 (16:11 -0500)]
[3.6] bpo-30160: Clarify intended usage of wfile (gh-1300) (GH-1793)
The library does not enforce compliance with the HTTP protocol,
so violations are not technically disallowed. Extend the stream's
description to avoid suggesting that intentional protocol violations are
not supported.
(cherry picked from commit a083c8e)
Łukasz Langa [Tue, 23 May 2017 05:23:29 +0000 (22:23 -0700)]
[3.6] bpo-23894: make lib2to3 recognize f-strings (GH-1733) (#1737)
Note: this doesn't unpack f-strings into the underlying JoinedStr AST.
Ideally we'd fully implement JoinedStr here but given its additional
complexity, I think this is worth bandaiding as is. This unblocks tools like
https://github.com/google/yapf to format 3.6 syntax using f-strings.
(cherry picked from commit 1b9530c536664276ce866ae602ce04adce0810e1)
head_lock could be held by another thread when fork happened. We should
reset it to avoid deadlock.
(cherry picked from commit f82c951d1c5416f3550d544e50ff5662d3836e73)
Victor Stinner [Wed, 17 May 2017 00:06:14 +0000 (17:06 -0700)]
bpo-30357: test_thread now uses threading_cleanup() (#1592) (#1622)
test_thread: setUp() now uses support.threading_setup() and
support.threading_cleanup() to wait until threads complete to avoid
random side effects on following tests.
* Use explicit numbering for footnotes referred by explicit number.
* Restore missed footnote reference in stdtypes.rst.
* Fix literal strings formatting in howto/urllib2.rst.
* Update susp-ignored.csv for zipapp.rst.
* Fix suspicious mark up in Misc/NEWS..
(cherry picked from commit d97b7dc94b19063f0589d401bdc4aaadc7030762)
Serhiy Storchaka [Tue, 16 May 2017 15:16:15 +0000 (18:16 +0300)]
[3.6] bpo-30375: Correct the stacklevel of regex compiling warnings. (GH-1595) (#1604)
Warnings emitted when compile a regular expression now always point
to the line in the user code. Previously they could point into inners
of the re module if emitted from inside of groups or conditionals..
(cherry picked from commit c7ac7280c321b3c1679fe5f657a6be0f86adf173)
Victor Stinner [Wed, 10 May 2017 06:47:22 +0000 (08:47 +0200)]
bpo-30320: test_eintr now uses pthread_sigmask() (#1523) (#1524)
Rewrite sigwaitinfo() and sigtimedwait() unit tests for EINTR using
pthread_sigmask() to fix a race condition between the child and the
parent process.
Remove the pipe which was used as a weak workaround against the race
condition.
sigtimedwait() is now tested with a child process sending a signal
instead of testing the timeout feature which is more unstable
(especially regarding to clock resolution depending on the platform).
(cherry picked from commit 211a392cc15f9a7b1b8ce65d8f6c9f8237d1b77f)