Fix the threading._shutdown() function when the threading module was
imported first from a thread different than the main thread: no
longer log an error at Python exit.
(cherry picked from commit 95d3137082)
Co-authored-by: Victor Stinner <vstinner@python.org>
_global_shutdown_lock should be reinitialized in forked children
(cherry picked from commit 0bfa1106ac)
Co-authored-by: nullptr <3621629+0x0L@users.noreply.github.com>
Automerge-Triggered-By: GH:gpshead
Calling Py_InitializeFromConfig()+Py_RunMain() multiple times must
not crash.
Cleanup also test_get_argc_argv().
(cherry picked from commit 5e2c32e08e)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit fcbf9b176b)
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
Instead of explicitly enumerate test classes for run_unittest()
use the unittest ability to discover tests. This also makes these
tests discoverable and runnable with unittest.
load_tests() can be used for dynamic generating tests and adding
doctests. setUpModule(), tearDownModule() and addModuleCleanup()
can be used for running code before and after all module tests.
(cherry picked from commit 40348acc18)
This can occur when the zip file gets deleted, you call zipimport.zipimporter.invalidate_cache(), and then try to use zipimport.zipimporter.find_spec() (i.e. you left the zip file path on sys.path).
(cherry picked from commit 209b7035f7)
Co-authored-by: Brett Cannon <brett@python.org>
Previously, test classes ISOTPTest, J1939Test, BasicUDPLITETest and
UDPLITETimeoutTest were not included in the list of tests and
were not run by regrtest.
(cherry picked from commit 0361335b80)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
tearDown() is not called if setUp() raises an exception
(including SkipTest). addCleanup() should be used for guaranteed
execution of the cleanup code.
(cherry picked from commit 7dacb70485)
Make test_compileall quiet: test_year_2038_mtime_compilation() and
test_larger_than_32_bit_times() of test_compileall no longer log
"Compiling ..." messages to stdout.
(cherry picked from commit cc057ff522)
Co-authored-by: Victor Stinner <vstinner@python.org>
test_gdb.test_pycfunction() now ignores gdb stderr, it no longer logs
messages like:
Function "meth_varargs" not defined.
(cherry picked from commit 84a6061e29)
Co-authored-by: Victor Stinner <vstinner@python.org>
test_pdb.test_checkline_is_not_executable() no longer writes output
to stdout.
Remove also unused variables 'f'.
(cherry picked from commit e08e491a6c)
Co-authored-by: Victor Stinner <vstinner@python.org>
Fix test_readline.test_nonascii(): sometimes, the newline character
is not written at the end, so don't expect it in the output.
(cherry picked from commit 797c8eb9ef)
Co-authored-by: Victor Stinner <vstinner@python.org>
* Calling guess_all_extensions() with strict=False potentially
mutated types_map_inv.
* Mutating the result of guess_all_extensions() mutated types_map_inv.
(cherry picked from commit 97ea18eced)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Update test_sysconfig.test_user_similar() for the posix_user scheme:
"platlib" doesn't use sys.platlibdir.
(cherry picked from commit 49acac00c0)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
(cherry picked from commit b4b6342848)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
* Use a private version of _PyType_GetQualName
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Fix regrtest second summary when using -w/--verbose2 command line
option: lists re-run tests in the second test summary.
(cherry picked from commit c4ea45d7d2)
Co-authored-by: Victor Stinner <vstinner@python.org>
It happened with fast range iterator when the calculated stop = start + step * len
was out of the C long range.
(cherry picked from commit 936f6a16b9)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
(cherry picked from commit 0635e201be)
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
Remove code which duplicates the functionality of TextTestResult.
(cherry picked from commit 2b76a5322f)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
PyPy and potentially other implementations have different or no
contraints on the number of blocks that can be statically nested. move
the test that checks for this behaviour into a unit test and mark it as
CPython-only.
(cherry picked from commit eb263f9a35)
Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
Various date parsing utilities in the email module, such as
email.utils.parsedate(), are supposed to gracefully handle invalid
input, typically by raising an appropriate exception or by returning
None.
The internal email._parseaddr._parsedate_tz() helper used by some of
these date parsing routines tries to be robust against malformed input,
but unfortunately it can still crash ungracefully when a non-empty but
whitespace-only input is passed. This manifests as an unexpected
IndexError.
In practice, this can happen when parsing an email with only a newline
inside a ‘Date:’ header, which unfortunately happens occasionally in the
real world.
Here's a minimal example:
$ python
Python 3.9.6 (default, Jun 30 2021, 10:22:16)
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import email.utils
>>> email.utils.parsedate('foo')
>>> email.utils.parsedate(' ')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.9/email/_parseaddr.py", line 176, in parsedate
t = parsedate_tz(data)
File "/usr/lib/python3.9/email/_parseaddr.py", line 50, in parsedate_tz
res = _parsedate_tz(data)
File "/usr/lib/python3.9/email/_parseaddr.py", line 72, in _parsedate_tz
if data[0].endswith(',') or data[0].lower() in _daynames:
IndexError: list index out of range
The fix is rather straight-forward: guard against empty lists, after
splitting on whitespace, but before accessing the first element.
(cherry picked from commit 989f6a3800)
Co-authored-by: wouter bolsterlee <wouter@bolsterl.ee>
The code of the test was never executed because the test function
was unintentionally converted to a generator function.
(cherry picked from commit 585390fdd8)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Because setting non-empty _name affects behavior of other code.
In most cases __name__ can be derived from __origin__.__name__.
(cherry picked from commit 4ceec49559)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Additional improvements:
- messages which were compiled regular expressions aren't unpacked back into
strings for unmatched warnings;
- removed unnecessary "if tokens:" check (there's one before the for loop);
- took `endswith` calculation out of the for loop.
(cherry picked from commit 8cf07d3db3)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This is part of an investigation of a non-deterministic reference leak. While we're looking for the root cause, this is included temporarily so that CI doesn't fail on this particular issue. This enables it to find other regressions in the meantime, which would otherwise be shadowed by our known issue.
(cherry picked from commit 7bf28cbb4b)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
On non-Linux POSIX platforms, like FreeBSD or macOS,
the FD used to read a forked PTY may signal its exit not
by raising an error but by sending empty data to the read
syscall. This case wasn't handled, leading to hanging
`pty.spawn` calls.
Co-authored-by: Reilly Tucker Siemens <reilly@tuckersiemens.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 81ab8db235)
Co-authored-by: Zephyr Shannon <geoffpshannon@gmail.com>
* When trying to allocate very large regions on macOS, malloc does not fail silently. It sends a noisy error out to STDERR
* This provides a helper function to warn the user, and provides the warning for test_decimal, which consistently generates these warnings on macOS.
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 15d3c14df3)
Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 8bdf12e99a)
Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com>
The threading debug (PYTHONTHREADDEBUG environment variable) is
deprecated in Python 3.10 and will be removed in Python 3.12. This
feature requires a debug build of Python.
(cherry picked from commit 4d77691172)
Co-authored-by: Victor Stinner <vstinner@python.org>
Non-protocol subclasses of protocol ignore now the __init__ method
inherited from protocol base classes.
(cherry picked from commit 043cd60abe)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
For example Callable[P, T][[int], str, float] will now raise an error.
Use also term "arguments" instead of "parameters" in error
message for too few/many arguments.
(cherry picked from commit f92b9133ef)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Addressing issues with tests under error on warnings.
Automerge-Triggered-By: GH:jaraco
(cherry picked from commit 1cf8424a62)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>