This PR adds missing details in the [`concurrent.futures`](https://docs.python.org/3/library/concurrent.futures.html) documentation:
* the mention that `Future.cancel` also returns `False` if the call finished running;
* the mention of the states for `Future` that did not complete: pending or running.
(cherry picked from commit 431478d5d7)
Co-authored-by: Géry Ogam <gery.ogam@gmail.com>
Fix a regression introduced by af8646c805 that was causing code of the form:
if True and False:
do_something()
to be optimized incorrectly, eliminating the block..
(cherry picked from commit 05f8318655)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Calling setlocale(LC_CTYPE, "") on a system where GetACP() returns CP_UTF8 results in empty strings in _tzname[].
This causes time.tzname to be an empty string.
I have reported the bug to the UCRT team and will follow up, but it will take some time get a fix into production.
In the meantime one possible workaround is to temporarily change the locale by calling setlocale(LC_CTYPE, "C") before calling _tzset and restore the current locale after if the GetACP() == CP_UTF8 or CP_UTF7
@zooba
https://bugs.python.org/issue36779
(cherry picked from commit b4c7defe58)
Co-authored-by: Paul Monson <paulmon@users.noreply.github.com>
* bpo-36402: Fix threading._shutdown() race condition (GH-13948)
Fix a race condition at Python shutdown when waiting for threads.
Wait until the Python thread state of all non-daemon threads get
deleted (join all non-daemon threads), rather than just wait until
Python threads complete.
* Add threading._shutdown_locks: set of Thread._tstate_lock locks
of non-daemon threads used by _shutdown() to wait until all Python
thread states get deleted. See Thread._set_tstate_lock().
* Add also threading._shutdown_locks_lock to protect access to
threading._shutdown_locks.
* Add test_finalization_shutdown() test.
(cherry picked from commit 468e5fec8a)
* bpo-36402: Fix threading.Thread._stop() (GH-14047)
Remove the _tstate_lock from _shutdown_locks, don't remove None.
(cherry picked from commit 6f75c87375)
(cherry picked from commit e40a97a721)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
Escape ``\r``, ``\0`` and ``\x1a`` (end-of-file on Windows) in Unicode strings.
(cherry picked from commit 38ab7d4721)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-29505: Enable fuzz testing of the json module, enforce size limit on int(x) fuzz and json input size to avoid timeouts.
Contributed by by Ammar Askar for Google.
(cherry picked from commit a6e190e94b)
Co-authored-by: Ammar Askar <aaskar@google.com>
Python 3.6 changed the size of bytecode instruction, while the documentation for `EXTENDED_ARG` was not updated accordingly.
(cherry picked from commit 405f648db7)
Co-authored-by: Yao Zuo <laike9m@users.noreply.github.com>
* [bpo-36520](https://bugs.python.org/issue36520): reset the encoded word offset when starting a new
line during an email header folding operation
* 📜🤖 Added by blurb_it.
* [bpo-36520](https://bugs.python.org/issue36520): add an additional test case, and provide descriptive
comments for the test_folding_with_utf8_encoding_* tests
* [bpo-36520](https://bugs.python.org/issue36520): fix whitespace issue
* [bpo-36520](https://bugs.python.org/issue36520): changes per reviewer request -- remove extraneous
backslashes; add whitespace between terminating quotes and
line-continuation backslashes; use "bpo-" instead of
"issue GH-" in comments
(cherry picked from commit f6713e84af)
Co-authored-by: websurfer5 <49998481+websurfer5@users.noreply.github.com>
https://bugs.python.org/issue36520
If preadv2 is not available, preadv will raise NotImplementedError.
(cherry picked from commit 44867bb937)
Co-authored-by: Benjamin Peterson <benjamin@python.org>
This test "works" if things are run in the right order, so it's better to use @skip than @expectedFailure here.
(cherry picked from commit 910b3fcb01)
Co-authored-by: Benjamin Peterson <benjamin@python.org>
If internal tasks weak set is changed by another thread during iteration.
https://bugs.python.org/issue36607
(cherry picked from commit 65aa64fae8)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
When the line is uncommented, the equals character causes it to be incorrectly interpreted
as a macro definition by makesetup. This results in invalid Makefile output.
The expat code only requires XML_POOR_ENTROPY to be defined; the value is unnecessary.
(cherry picked from commit 408a2ef1ac)
Co-authored-by: aaronpaulhurst <aaronpaulhurst@gmail.com>
Currently, inspect.getfile(str) will report nonsense:
```pytb
>>> inspect.getfile(str)
TypeError: <module 'builtins' (built-in)> is a built-in class
```
This fixes that
https://bugs.python.org/issue37173
(cherry picked from commit d407d2a726)
Co-authored-by: Philipp A <flying-sheep@web.de>
Fix an unintended ValueError from :func:`subprocess.run` when checking for
conflicting `input` and `stdin` or `capture_output` and `stdout` or `stderr` args
when they were explicitly provided but with `None` values within a passed in
`**kwargs` dict rather than as passed directly by name.
(cherry picked from commit 8cc605acdd)
Co-authored-by: Rémi Lapeyre <remi.lapeyre@henki.fr>
* Change from Dummy_Editwin to DummyEditwin to match other tests.
(cherry picked from commit 7f8a38a7c4)
Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
This avoids the search dialogs being hidden behind the editor window.
(cherry picked from commit 554450fb4e)
Co-authored-by: Tal Einat <taleinat@gmail.com>
* bpo-21315: Fix parsing of encoded words with missing leading ws.
Because of missing leading whitespace, encoded word would get parsed as
unstructured token. This patch fixes that by looking for encoded words when
splitting tokens with whitespace.
Missing trailing whitespace around encoded word now register a defect
instead.
Original patch suggestion by David R. Murray on bpo-21315.
(cherry picked from commit 66c4f3f38b)
Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
When an attribute is deleted from a Mock, a sentinel is added rather
than just deleting the attribute. This commit checks for such sentinels
when returning the child mocks in the __dir__ method as users won't
expect deleted attributes to appear when performing dir(mock).
(cherry picked from commit 0df635c7f8)
Co-authored-by: Mario Corchero <mariocj89@gmail.com>
* bpo-30835: email: Fix AttributeError when parsing invalid Content-Transfer-Encoding
Parsing an email containing a multipart Content-Type, along with a
Content-Transfer-Encoding containing an invalid (non-ASCII-decodable) byte
will fail. email.feedparser.FeedParser._parsegen() gets the header and
attempts to convert it to lowercase before comparing it with the accepted
encodings, but as the header contains an invalid byte, it's returned as a
Header object rather than a str.
Cast the Content-Transfer-Encoding header to a str to avoid this.
Found using the AFL fuzzer.
Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Andrew Donnellan <andrew@donnellan.id.au>
* Add email and NEWS entry for the bugfix.
(cherry picked from commit aa79707262)
Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
Add it to the end of the first line if there is room. Tests were reworked.
(cherry picked from commit 949fe976d5)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
test_venv.test_mutiprocessing() now explicitly calls pool.terminate()
to wait until the pool completes.
(cherry picked from commit bc6469f79c)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
* Improve example on tzinfo instances
Move from GMTX to TZX when naming the classes, as GMT1 might be rather
confusing as seen in the reported issue.
In addition, move to UTC over GMT and improve the tzname implementation.
* Simplify datetime with tzinfo example
Move the example in the documentation to just use timezone.utc and a
user defined Kabul timezone rather than having two user defined
timezones with DST.
Kabul timezone is still interesting as it changes its offset but not
based on DST. This is more accurate as the previous example was missing
information about the fold attribute. Additionally, implementing the fold
attribute was rather complex and probably not relevant enough for the
section "datetime with tzinfo".
(cherry picked from commit f0b5ae4567)
Co-authored-by: Mario Corchero <mcorcherojim@bloomberg.net>
What's new now mentions SSLContext.hostname_checks_common_name instead of SSLContext.host_flags.
https://bugs.python.org/issue36868
(cherry picked from commit 47eb223406)
Co-authored-by: Christian Heimes <christian@python.org>
Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 06651ee418)
Co-authored-by: Christian Heimes <christian@python.org>
https://bugs.python.org/issue37081
* bpo-19184: Update the documentation of dis module
* Explain the behavior of the number of arguments of RAISE_VARGARGS
opcode.
* bpo-19184: Update blurb.
* bpo-19184: Fix typo in the dis Documentation.
* bpo-19184: Address review comments and improve the doc
* bpo-19184: Remove news file.
(cherry picked from commit e1179a5096)
Co-authored-by: Michele Angrisano <michele.angrisano@gmail.com>
* bpo-37014: Update docstring and Documentation of fileinput.FileInput()
* Explain the behavior of fileinput.FileInput() when reading stdin.
* Update blurb.
* bpo-37014: Fix typo in the docstring and documentation.
(cherry picked from commit aca273e240)
Co-authored-by: Michele Angrisano <michele.angrisano@gmail.com>
Changes in bpo- 31858 made the less informative 'context_use_ps1' redundant.
(cherry picked from commit 6bdc4dee01)
Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
Insertion in line order makes sorting keys by line order unneeded.
(cherry picked from commit 1a4d9ffa1a)
Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
bytesio_sizeof() must check if an error has occurred in _PySys_GetSizeOf().
(cherry picked from commit 36dcaab7fd)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>