* Revert "[3.11] gh-101634: regrtest reports decoding error as failed test (#106169) (#106175)"
This reverts commit d5418e97fc.
* Revert "[3.11] bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (GH-30895) (GH-103342)"
This reverts commit ecb09a8496.
* Revert "gh-95027: Fix regrtest stdout encoding on Windows (GH-98492)"
This reverts commit b2aa28eec5.
* Revert "[3.11] gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253) (GH-94408)"
This reverts commit 0122ab235b.
* Revert "Run Tools/scripts/reindent.py (GH-94225)"
This reverts commit f0f3a424af.
* Revert "gh-94052: Don't re-run failed tests with --python option (GH-94054)"
This reverts commit 1347607db1.
* Revert "[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)"
This reverts commit 1073184918.
* gh-93353: regrtest checks for leaked temporary files (#93776)
When running tests with -jN, create a temporary directory per process
and mark a test as "environment changed" if a test leaks a temporary
file or directory.
(cherry picked from commit e566ce5496)
* gh-93353: Fix regrtest for -jN with N >= 2 (GH-93813)
(cherry picked from commit 36934a16e8)
* gh-93353: regrtest supports checking tmp files with -j2 (#93909)
regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
(cherry picked from commit 4f85cec9e2)
* gh-84461: Fix Emscripten umask and permission issues (GH-94002)
- Emscripten's default umask is too strict, see
https://github.com/emscripten-core/emscripten/issues/17269
- getuid/getgid and geteuid/getegid are stubs that always return 0
(root). Disable effective uid/gid syscalls and fix tests that use
chmod() current user.
- Cannot drop X bit from directory.
(cherry picked from commit 2702e408fd)
* gh-94052: Don't re-run failed tests with --python option (#94054)
(cherry picked from commit 0ff7b996f5)
* Run Tools/scripts/reindent.py (#94225)
Reindent files which were not properly formatted (PEP 8: 4 spaces).
Remove also some trailing spaces.
(cherry picked from commit e87ada48a9)
* gh-94026: Buffer regrtest worker stdout in temporary file (GH-94253)
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 199ba23324)
* gh-96465: Clear fractions hash lru_cache under refleak testing (GH-96689)
Automerge-Triggered-By: GH:zware
(cherry picked from commit 9c8f379433)
* gh-95027: Fix regrtest stdout encoding on Windows (#98492)
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f13)
* gh-98903: Test suite fails with exit code 4 if no tests ran (#98904)
The Python test suite now fails wit exit code 4 if no tests ran. It
should help detecting typos in test names and test methods.
* Add "EXITCODE_" constants to Lib/test/libregrtest/main.py.
* Fix a typo: "NO TEST RUN" becomes "NO TESTS RAN"
(cherry picked from commit c76db37c0d)
* gh-100086: Add build info to test.libregrtest (#100093)
The Python test runner (libregrtest) now logs Python build information like
"debug" vs "release" build, or LTO and PGO optimizations.
(cherry picked from commit 3c89202247)
* bpo-46523: fix tests rerun when `setUp[Class|Module]` fails (#30895)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 995386071f)
* gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.
After porting we can see the direct impact on a multicore system.
Without this change:
Running make test is 5 min 26 seconds
With this change:
Running make test takes 3 min 39 seconds
That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.
The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.
Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.
---------
Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
(cherry picked from commit 9e011e7c77)
* Display the sanitizer config in the regrtest header. (#105301)
Display the sanitizers present in libregrtest.
Having this in the CI output for tests with the relevant environment
variable displayed will help make it easier to do what we need to
create an equivalent local test run.
(cherry picked from commit 852348ab65)
* gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103)
* gh-108223: test.pythoninfo and libregrtest log Py_NOGIL (#108238)
Enable with --disable-gil --without-pydebug:
$ make pythoninfo|grep NOGIL
sysconfig[Py_NOGIL]: 1
$ ./python -m test
...
== Python build: nogil debug
...
(cherry picked from commit 5afe0c17ca)
* gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
(cherry picked from commit 3a1ac87f8f)
* gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".
Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.
(cherry picked from commit 174e9da083)
* regrtest computes statistics (#108793)
test_netrc, test_pep646_syntax and test_xml_etree now return results
in the test_main() function.
Changes:
* Rewrite TestResult as a dataclass with a new State class.
* Add test.support.TestStats class and Regrtest.stats_dict attribute.
* libregrtest.runtest functions now modify a TestResult instance
in-place.
* libregrtest summary lists the number of run tests and skipped
tests, and denied resources.
* Add TestResult.has_meaningful_duration() method.
* Compute TestResult duration in the upper function.
* Use time.perf_counter() instead of time.monotonic().
* Regrtest: rename 'resource_denieds' attribute to 'resource_denied'.
* Rename CHILD_ERROR to MULTIPROCESSING_ERROR.
* Use match/case syntadx to have different code depending on the
test state.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit d4e534cbb3)
* gh-108822: Add Changelog entry for regrtest statistics (#108821)
---------
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Zachary Ware <zach@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Joshua Herman <zitterbewegung@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
For example, do not demand the 'cpu' resource if the test cannot be run
due to non-working threads.
(cherry picked from commit 509bb61977)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-107275 introduced a regression where a SemLock would fail being passed along nested child processes, as the `is_fork_ctx` attribute would be left missing after the first deserialization.
---------
(cherry picked from commit add8d45cbe)
Co-authored-by: albanD <desmaison.alban@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
Add test_sqlite_row_keys() to explicitly test sqlite3.Row.keys().
Cleanups:
- Reduce test noise by converting docstrings to regular comments
- Reduce boilerplate code by adding a setUp() method to RowFactoryTests
(cherry picked from commit 6eaddc10e9)
Co-authored-by: Edward Schauman-Haigh <142528725+EddInSverige@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
gh-105821: Use a raw f-string in test_httpservers.py (GH-105822)
Use a raw f-string in test_httpservers.py
(cherry picked from commit 09ce8c3b48)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Disable the busy handler for all concurrency tests; we have full
control over the order of the SQLite C API calls, so we can safely
do this.
test_sqlite3.test_transactions now completes ~10 times faster than before.
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* In preauth tests of test_ssl, explicitly break reference cycles
invoving SingleConnectionTestServerThread to make sure that the
thread is deleted. Otherwise, the test marks the environment as
altered because the threading module sees a "dangling thread"
(SingleConnectionTestServerThread). This test leak was introduced
by the test added for the fix of issue gh-108310.
* Use support.SHORT_TIMEOUT instead of hardcoded 1.0 or 2.0 seconds
timeout.
* SingleConnectionTestServerThread.run() catchs TimeoutError
* Fix a race condition (missing synchronization) in
test_preauth_data_to_tls_client(): the server now waits until the
client connect() completed in call_after_accept().
* test_https_client_non_tls_response_ignored() calls server.join()
explicitly.
* Replace "localhost" with server.listener.getsockname()[0].
(cherry picked from commit 592bacb6fc)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-77377: Ensure multiprocessing SemLock is valid for spawn-based Process before serializing it (GH-107275)
Ensure multiprocessing SemLock is valid for spawn Process before serializing it.
Creating a multiprocessing SemLock with a fork context, and then trying to pass it to a spawn-created Process, would segfault if not detected early.
---------
(cherry picked from commit 1700d34d31)
Co-authored-by: albanD <desmaison.alban@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
gh-105776: Fix test_cppext when CC contains -std=c11 option (#108343)
Fix test_cppext when the C compiler command has the "-std=c11" option.
Remove "-std=" options from the compiler command.
(cherry picked from commit 9173b2bbe1)
gh-108303: Add Lib/test/test_cppext/ sub-directory (#108325)
* Move test_cppext to its own directory
* Rename setup_testcppext.py to setup.py
* Rename _testcppext.cpp to extension.cpp
* The source (extension.cpp) is now also copied by the test.
(cherry picked from commit 21dda09600)
gh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw
Instances of `ssl.SSLSocket` were vulnerable to a bypass of the TLS handshake
and included protections (like certificate verification) and treating sent
unencrypted data as if it were post-handshake TLS encrypted data.
The vulnerability is caused when a socket is connected, data is sent by the
malicious peer and stored in a buffer, and then the malicious peer closes the
socket within a small timing window before the other peers’ TLS handshake can
begin. After this sequence of events the closed socket will not immediately
attempt a TLS handshake due to not being connected but will also allow the
buffered data to be read as if a successful TLS handshake had occurred.
Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
gh-106016: Add Lib/test/test_module/ directory (GH-108293)
* Move Python scripts related to test_module to this new directory:
good_getattr.py and bad_getattrX.py scripts.
* Move Lib/test/test_module.py to Lib/test/test_module/__init__.py.
(cherry picked from commit adfc118fda)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-106242: Make ntpath.realpath errors consistent with abspath when there are embedded nulls (GH-108248)
---------
(cherry picked from commit de33b5c662)
Co-authored-by: Steve Dower <steve.dower@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
gh-107396: tarfiles: set self.exception before _init_read_gz() (GH-107485)
In the stack call of: _init_read_gz()
```
_read, tarfile.py:548
read, tarfile.py:526
_init_read_gz, tarfile.py:491
```
a try;except exists that uses `self.exception`, so it needs to be set before
calling _init_read_gz().
(cherry picked from commit 37135d25e2)
Co-authored-by: balmeida-nokia <83089745+balmeida-nokia@users.noreply.github.com>
Restore the global Input Stream pointer after trying to match a sub-pattern.
Co-authored-by: Ma Lin <animalize@users.noreply.github.com>
(cherry picked from commit abd9cc52d9)
Co-authored-by: SKO <41810398+uyw4687@users.noreply.github.com>
Restore following CPython <= 3.10.5 behavior of shutil.make_archive()
that went away as part of gh-93160:
Do not create an empty archive if root_dir is not a directory, and, in
that case, raise FileNotFoundError or NotADirectoryError regardless
of format choice. Beyond the brought-back behavior, the function may
now also raise these exceptions in dry_run mode.
(cherry picked from commit a86df298df)
Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
gh-107963: Fix set_forkserver_preload to check the type of given list (GH-107965)
(cherry picked from commit 6515ec3d3d)
gh-107963: Fix set_forkserver_preload to check the type of given list
Co-authored-by: Dong-hee Na <donghee.na@python.org>
* Strings with length from 2**31-1 to 2**32-2 always caused MemoryError,
it doesn't matter how much memory is available.
* Strings with length exactly 2**32-1 caused OSError.
* Strings longer than 2**32-1 characters were truncated due to integer overflow bug.
Now strings longer than 2**31-1 characters caused OverflowError.
(cherry picked from commit 04cc01453d)
It did not work in the case of a subpattern containing backtracking.
Temporary implement possessive quantifiers as equivalent greedy qualifiers
in atomic groups.
(cherry picked from commit 7b6e34e5ba)
Instead of hacking into the Clinic class, use the Argument Clinic tool
to run the ClinicExternalTest test suite.
(cherry picked from commit 83a2837b32)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
gh-107237: Fix test_udp_reconnection() of test_logging (#107238)
test_logging: Fix test_udp_reconnection() by increasing the timeout
from 100 ms to 5 minutes (LONG_TIMEOUT).
Replace also blocking wait() with wait(LONG_TIMEOUT) in
test_output() to prevent the test to hang.
(cherry picked from commit ed08238327)
Add test for the 'destination <name> clear' command,
and the 'destination' directive in general.
Fix two bugs in 'destination <name> clear' command:
1. The text attribute of the allocator is called 'text', not '_text'
2. Return after processing the 'clear' command,
instead of proceeding directly to the fail().
(cherry picked from commit 3372bcba98)
[3.11] gh-105235: Prevent reading outside buffer during mmap.find() (GH-105252)
* Add a special case for s[-m:] == p in _PyBytes_Find
* Add tests for _PyBytes_Find
* Make sure that start <= end in mmap.find.
(cherry picked from commit ab86426a34)
gh-102541: Add test case for help() for non_existent_module (GH-106340)
Test fix for when one enters, for instance, 'abd' at the 'help>' prompt.
---------
(cherry picked from commit 292ac4bfe9)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
gh-106498: Revert incorrect colorsys.rgb_to_hls change (GH-106627)
gh-86618 assumed a-b-c = a-(b+c) = a-d where d = b+d.
For floats 2.0, 1.0, and 0.9999999999999999, this assumption
is false. The net change of 1.1102230246251565e-16 to 0.0
results in division by 0. Revert the replacement. Add test.
(cherry picked from commit a2d54d4e8a)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
gh-105497: [Enum] Fix flag mask inversion when unnamed flags exist (GH-106468)
For example:
class Flag(enum.Flag):
A = 0x01
B = 0x02
MASK = 0xff
~Flag.MASK is Flag(0)
(cherry picked from commit 95b7426f45)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
gh-94777: Fix deadlock in ProcessPoolExecutor (GH-94784)
Fixes a hang in multiprocessing process pool executor when a child process crashes and code could otherwise block on writing to the pipe. See GH-94777 for more details.
(cherry picked from commit 6782fc0502)
Co-authored-by: Louis Paulot <55740424+lpaulot@users.noreply.github.com>
Reduce test noise by fixing or catching and testing stderr messages from individual tests.
test_cmd_line_script.test_script_as_dev_fd calls spawn_python and hence subprocess.Popen with incompatible arguments. On POSIX, pass_fds forces close_fds to be True (subprocess.py line 848). Correct the call.
test_uuid.test_cli_namespace_required_for_uuid3: when the namespace is omitted, uuid.main calls argparse.Argument_Parser.error, which prints to stderr before calling sys.exit, which raises SystemExit. Unittest assertRaises catches the exception but not the previous output. Catch the output and test it.
test_warnings.test_catchwarnings_with_simplefilter_error similarly prints before raising. Catch the output and test it.
---------
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
(cherry picked from commit 9d582250d8)
gh-90876: Restore the ability to import multiprocessing when `sys.executable` is `None` (GH-106464)
Prevent `multiprocessing.spawn` from failing to *import* in environments
where `sys.executable` is `None`. This regressed in 3.11 with the addition
of support for path-like objects in multiprocessing.
Adds a test decorator to have tests only run when part of test_multiprocessing_spawn to `_test_multiprocessing.py` so we can start to avoid re-running the same not-global-state specific test in all 3 modes when there is no need.
(cherry picked from commit c60df361ce)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
When inverting a Flag member (or boundary STRICT), only consider other canonical flags; when inverting an IntFlag member (or boundary KEEP), also consider aliases.
(cherry picked from commit 59f009e589)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
gh-102541: Fix Helper.help("mod") for non-existent mod (GH-105934)
If the output arg to Helper() is a stream rather than the default None, which means 'page to stdout', the ImportError from pydoc.resolve is currently not caught in pydoc.doc. The same error is caught when output is None.
---------
(cherry picked from commit 0530f4f646)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
gh-101634: regrtest reports decoding error as failed test (#106169)
When running the Python test suite with -jN option, if a worker stdout
cannot be decoded from the locale encoding report a failed testn so the
exitcode is non-zero.
(cherry picked from commit 2ac3eec103)
GH-105840: Fix assertion failures when specializing calls with too many __defaults__ (GH-105847)
(cherry picked from commit 2beab5bdef)
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
gh-105436: The environment block should end with two null wchar_t values (GH-105495)
(cherry picked from commit 4f7d3b602d)
Co-authored-by: Dora203 <66343334+sku2000@users.noreply.github.com>
test_func_return_too_large_int() was defined twice.
Keep only the redefined method, as that also checks the tracebacks.
(cherry picked from commit b8fa7bda4f)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Fix test_importlib.test_side_effect_import() (GH-104840)
Wait until the thread spawn by the import completes to avoid dangling
threads. With this fix, the following command no longer fails:
./python -m test --fail-env-changed test_importlib -m test_side_effect_import -F -j20
(cherry picked from commit 426950993f)
Co-authored-by: Victor Stinner <vstinner@python.org>
In particular, it's important to test that is_typeddict(TypedDict)
returns False.
(cherry picked from commit 1497607a8e)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
[3.12] gh-104271: Fix auto() fallback in case of mixed type Enum (GH-104279)
(cherry picked from commit f4e2049f14)
Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
* gh-103606: Improve error message from logging.config.FileConfig (GH-103628)
(cherry picked from commit 152227b569)
plus backport the followup exception change fix to that in #104701
gh-104472: Skip `test_subprocess.ProcessTestCase.test_empty_env` if ASAN is enabled (GH-104667)
Skip test_subprocess.ProcessTestCase.test_empty_env if ASAN is enabled.
(cherry picked from commit c3f43bfb4b)
Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
Utilize new functions termios.tcgetwinsize() and termios.tcsetwinsize in test_pty.py.
(cherry picked from commit da2fb92643)
Co-authored-by: Soumendra Ganguly <67527439+8vasu@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
gh-104629: Don't skip test_clinic if _testclinic is missing (GH-104630)
Just skip the tests that depend on the _testclinic extension module;
we can still run the Python tests.
(cherry picked from commit 86ee49f469)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
During the PEP 695 implementation at one point I made
TypeVar.__name__ return garbage, and all of test_typing passed.
So I decided to add a few more tests.
(cherry picked from commit 26931944dd)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Fix Zip64 extensions not being properly applied in some cases:
Fixes an issue where adding a small file to a `ZipFile`
object while forcing zip64 extensions causes an extra Zip64 record to be
added to the zip, but doesn't update the `min_version` or file sizes in
the primary central directory header.
Also fixed an edge case in checking if zip64 extensions are required:
This fixes an issue where if data requiring zip64 extensions was added
to an unseekable stream without specifying `force_zip64=True`, zip64
extensions would not be used and a RuntimeError would not be raised when
closing the file (even though the size would be known at that point).
This would result in successfully writing corrupt zip files.
Deciding if zip64 extensions are required outside of the `FileHeader`
function means that both `FileHeader` and `_ZipWriteFile` will always be
in sync. Previously, the `FileHeader` function could enable zip64
extensions without propagating that decision to the `_ZipWriteFile`
class, which would then not correctly write the data descriptor record
or check for errors on close.
If anyone is actually using `ZipInfo.FileHeader` as a public API without
explicitly passing True or False in for zip64, their own code may still be
susceptible to that kind of bug unless they make a similar change to
where the zip64 decision happens.
Fixes GH-103861
---------
.
(cherry picked from commit 798bcaa1eb)
Co-authored-by: Carey Metcalfe <carey@cmetcalfe.ca>
gh-75367: Fix data descriptor detection in inspect.getattr_static (GH-104517)
(cherry picked from commit 5e9f471e7d)
Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
Co-authored-by: Carl Meyer <carl@oddbird.net>
GH-71383: IDLE - Document testing subsets of modules (GH-104463)
(cherry picked from commit 080a596152)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
gh-103204: `http.server` - Enforce that HTTP version numbers must consist only of digits (GH-103205)
Reject HTTP requests with invalid http/x.y version numbers: x or y being non-digits or too-long.
---------
(cherry picked from commit cf720acfcb)
Co-authored-by: Ben Kallus <49924171+kenballus@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Fix issue where `pathlib.Path.glob()` raised `OSError` when it encountered
a symlink to an overly long path.
(cherry picked from commit a33ce66dca)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
gh-103247: clear the module cache in a test in test_importlib/extensions/test_loader.py (GH-104226)
(cherry picked from commit 22f3425c3d)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
gh-103848: Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format (GH-103849)
* Adds checks to ensure that bracketed hosts found by urlsplit are of IPv6 or IPvFuture format
---------
(cherry picked from commit 29f348e232)
Co-authored-by: JohnJamesUtley <81572567+JohnJamesUtley@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
gh-103193: Improve `getattr_static` test coverage (GH-104286)
(cherry picked from commit 921185ed05)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Re-enable commented-out test in test_generators.py (GH-104130)
(cherry picked from commit 472938316a)
Co-authored-by: ymki4360 <132453923+ymki4360@users.noreply.github.com>
gh-101640: Make argparse _print_message catch any write error (GH-101802)
* In particular, don't exit when trying to print to stderr = None.
* Add tests
(cherry picked from commit 42f54d1f92)
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
gh-104049: do not expose on-disk location from SimpleHTTPRequestHandler (GH-104067)
Do not expose the local server's on-disk location from `SimpleHTTPRequestHandler` when generating a directory index. (unnecessary information disclosure)
---------
(cherry picked from commit c7c3a60c88)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
GH-103472: close response in HTTPConnection._tunnel (GH-103473)
Avoid a potential `ResourceWarning` in `http.client.HTTPConnection`
by closing the proxy / tunnel's CONNECT response explicitly.
---------
(cherry picked from commit 9de0cf20fa)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
gh-104018: disallow "z" format specifier in %-format of byte strings (GH-104033)
PEP-0682 specified that %-formatting would not support the "z" specifier,
but it was unintentionally allowed for bytes. This PR makes use of the "z"
flag an error for %-formatting in a bytestring.
Issue: GH-104018
---------
(cherry picked from commit 3ed8c88290)
Co-authored-by: John Belmonte <john@neggie.net>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
gh-104035: Do not ignore user-defined `__{get,set}state__` in slotted frozen dataclasses (GH-104041)
(cherry picked from commit 99aab61062)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
gh-104036: Fix direct invocation of test_typing (GH-104037)
Previously, `python -m test test_typing` worked, but `python Lib/test/test_typing.py` did not.
(cherry picked from commit 4181d078fc)
Co-authored-by: Kirill Podoprigora <80244920+Eclips4@users.noreply.github.com>
gh-103607: Fix `pause_reading` to work when called from `connection_made` in `asyncio`. (GH-17425)
(cherry picked from commit 78942ecd9b)
Co-authored-by: Itayazolay <itayazolay@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
`pdb` should use `io.open_code` to open code to avoid encoding issue.
(cherry picked from commit 31acfd78a0)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Revert "Add tests for empty range equality (GH-103751)" (GH-103770)
This reverts commit dca27a69a8.
Added tests are redundant with existing tests.
(cherry picked from commit ab25c7e311)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
gh-103746: Test `types.UnionType` and `Literal` types together (GH-103747)
(cherry picked from commit 3d29edaf0a)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
gh-103592: Add tests of `Literal` with `Enum` and `Union` of `Literal`s (GH-103706)
(cherry picked from commit 5041c2ba6e)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-81403: Fix for CacheFTPHandler in urllib (GH-13951)
bpo-37222: Fix for CacheFTPHandler in urllib
A call to FTP.ntransfercmd must be followed by FTP.voidresp to clear
the "end transfer" message. Without this, the client and server get
out of sync, which will result in an error if the FTP instance is
reused to open a second URL. This scenario occurs for even the most
basic usage of CacheFTPHandler.
Reverts the patch merged as a resolution to bpo-16270 and adds a test
case for the CacheFTPHandler in test_urllib2net.py.
(cherry picked from commit e38bebb9ee)
Co-authored-by: Dan Hemberger <846186+hemberger@users.noreply.github.com>
Co-authored-by: Senthil Kumaran <senthil@python.org>
* Added NEWS entry.
---------
Co-authored-by: Dan Hemberger <846186+hemberger@users.noreply.github.com>
Co-authored-by: Senthil Kumaran <senthil@python.org>
a mixin must either have a __new__ method, or be a dataclass, to be interpreted as a data-type; an __init__ method is not enough (restores pre-3.11 behavior for non-dataclasses).
(cherry picked from commit a6f95941a3)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
STRICT boundary:
- fix bitwise operations
- make default for Flag
(cherry picked from commit 2194071540)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* Quote paths in os.spawn tests on Windows so they work with spaces
* Add NEWS entry for os spawn test fix
* Fix code style to avoid double negative in os.spawn tests
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
---------
(cherry picked from commit a34c796238)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
GH-25309 enabled SSL_OP_IGNORE_UNEXPECTED_EOF by default, with a comment
that it restores OpenSSL 1.1.1 behavior, but this wasn't quite right.
That option causes OpenSSL to treat transport EOF as the same as
close_notify (i.e. SSL_ERROR_ZERO_RETURN), whereas Python actually has
distinct SSLEOFError and SSLZeroReturnError exceptions. (The latter is
usually mapped to a zero return from read.) In OpenSSL 1.1.1, the ssl
module would raise them for transport EOF and close_notify,
respectively. In OpenSSL 3.0, both act like close_notify.
Fix this by, instead, just detecting SSL_R_UNEXPECTED_EOF_WHILE_READING
and mapping that to the other exception type.
There doesn't seem to have been any unit test of this error, so fill in
the missing one. This had to be done with the BIO path because it's
actually slightly tricky to simulate a transport EOF with Python's fd
based APIs. (If you instruct the server to close the socket, it gets
confused, probably because the server's SSL object is still referencing
the now dead fd?)
(cherry picked from commit 420bbb783b)
Co-authored-by: David Benjamin <davidben@google.com>
Previously, this used to fail:
```py
from typing import *
T = TypeVar("T")
P = ParamSpec("P")
class X(Generic[P]):
f: Callable[P, int]
Y = X[[int, T]]
Z = Y[str]
```
(cherry picked from commit adb0621652)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Also use `raise TimeOut from <CancelledError instance>` so that the CancelledError is set
in the `__cause__` field rather than in the `__context__` field.
(cherry picked from commit 04adf2df39)
Co-authored-by: Kristján Valur Jónsson <sweskman@gmail.com>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
The size of the returned data is too implementation specific.
(cherry picked from commit 61405da9a5)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Fix an issue of concurrent.futures ProcessPoolExecutor shutdown hanging.
(cherry picked from commit 2dc94634b5)
Co-authored-by: yonatanp <yonatan.perry@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
---------
(cherry picked from commit 5e0865f22e)
Co-authored-by: Andre Hora <andrehora@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
It is possible but unlikely for the `python_tzpath_context` function to fail between the start of the `try` block and the point where `os.environ.get` succeeds, in which case `old_env` will be undefined. In this case, we want to take no action.
Practically speaking this will really only happen in an error condition anyway, so it doesn't really matter, but we should probably do it right anyway.
(cherry picked from commit 64bde502cf)
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
(cherry picked from commit 1a84cc007e)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
As part of investigation issue https://github.com/python/cpython/issues/102433, I discovered what I believe to be an error where two classes `CI` and `DI` are not being used. The assertions beneath them act on `C` and `D`, duplicating existing assertions in this test.
(cherry picked from commit 7894bbe94b)
Co-authored-by: JosephSBoyle <48555120+JosephSBoyle@users.noreply.github.com>
Automerge-Triggered-By: GH:AlexWaygood
Add thrashcan macros to the deallocator of the filter objects to protect against deeply nested destruction of chains of nested filters.
(cherry picked from commit 66aa78cbe6)
Co-authored-by: Marta Gómez Macías <mgmacias@google.com>
Add tests for conversion from bool to complex.
(cherry picked from commit 4197043637)
Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
gh-95675: fix uid and gid at test_add_dir_getmember (gh-102207)
(cherry picked from commit 56e93c8020)
Co-authored-by: Seonkyo Ok <seonkyo.ok@linecorp.com>
---------
(cherry picked from commit 9f3ecd1aa3)
Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
gh-101936: Update the default value of fp from io.StringIO to io.BytesIO (gh-102100)
(cherry picked from commit 0d4c7fcd4f)
Co-authored-by: Long Vo <long.vo@linecorp.com>
gh-101961 fileinput.hookcompressed should not set the encoding value for the binary mode (gh-102068)
(cherry picked from commit 6f25657b83)
Co-authored-by: Gihwan Kim <gihwan.kim@linecorp.com>
Previously, any data _after_ the zip64 extra would be removed.
With many new tests.
Fixes GH-88233
(cherry picked from commit 59e86caca8)
Co-authored-by: Tim Hatch <tim@timhatch.com>
Automerge-Triggered-By: GH:jaraco
Items checked by this test are always `str` and `dict` instances.
(cherry picked from commit eb49d32b9a)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
testBytesOpen requires an ASCII filename, but TESTFN usually isn't ASCII.
(cherry picked from commit 6fd5eb640a)
Co-authored-by: Zachary Ware <zach@python.org>
That causes the test to fail when run using a high UID as that ancient format
cannot represent it. The current default (PAX) and the old default (GNU) both
support high UIDs.
(cherry picked from commit ffcb8220d7)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Fix the behaviour of the `__sizeof__` method (and hence the results returned
by `sys.getsizeof`) for subclasses of `int`. Previously, `int` subclasses gave
identical results to the `int` base class, ignoring the presence of the instance
dictionary.
(Manual backport of #101394 to the Python 3.11 branch.)
The zipfile.Path open() and read_text() encoding parameter can be supplied as a positional argument without causing a TypeError again. 3.10.0b1 included a regression that made it keyword only.
Documentation update included as users writing code to be compatible with a wide range of versions will need to consider this for some time..
(cherry picked from commit 5927013e47)
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google]
This brings the Python implementation of `ntpath.normpath()` in line with the C implementation added in 99fcf15
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
gh-100637: Fix int and bool __sizeof__ calculation to include the 1 element ob_digit array for 0 and False (GH-100663)
Fixes behaviour where int (and subtypes like bool) __sizeof__ under-reports true size as it did not take into account the size 1 `ob_digit` array for the zero int.
(cherry picked from commit d7e7f79ca7)
Co-authored-by: Ionite <dev@ionite.io>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
This makes a couple related changes to inspect.signature's behaviour
when parsing a signature from `__text_signature__`.
First, `inspect.signature` is documented as only raising ValueError or
TypeError. However, in some cases, we could raise RuntimeError. This PR
changes that, thereby fixing GH-83685.
(Note that the new ValueErrors in RewriteSymbolics are caught and then
reraised with a message)
Second, `inspect.signature` could randomly drop parameters that it
didn't understand (corresponding to `return None` in the `p` function).
This is the core issue in GH-85267. I think this is very surprising
behaviour and it seems better to fail outright.
Third, adding this new failure broke a couple tests. To fix them (and to
e.g. allow `inspect.signature(select.epoll.register)` as in GH-85267), I
add constant folding of a couple binary operations to RewriteSymbolics.
(There's some discussion of making signature expression evaluation
arbitrary powerful in GH-68155. I think that's out of scope. The
additional constant folding here is pretty straightforward, useful, and
not much of a slippery slope)
Fourth, while GH-85267 is incorrect about the cause of the issue, it turns
out if you had consecutive newlines in __text_signature__, you'd get
`tokenize.TokenError`.
Finally, the `if name is invalid:` code path was dead, since
`parse_name` never returned `invalid`..
(cherry picked from commit 79311cbfe7)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
test.test_ast_recursion_limit() now uses infinite_recursion() of
test.support to prevent crashes on debug builds.
Before this change, the test crashed on ARM64 Windows 3.x buildbot
worker which builds Python in debug mode.
(cherry picked from commit cd67c1bb30)
Co-authored-by: Victor Stinner <vstinner@python.org>
When checking for auto() instances, only top-level usage is supported,
which means either alone or as part of a regular tuple. Other
containers, such as lists, dicts, or namedtuples, will not have auto()
transformed into a value.
(cherry picked from commit ded02ca54d)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Also \ escape \s in the http.server BaseHTTPRequestHandler.log_message so
that it is technically possible to parse the line and reconstruct what the
original data was. Without this a \xHH is ambiguious as to if it is a hex
replacement we put in or the characters r"\x" came through in the original
request line.
(cherry picked from commit 7e29398407)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Replace control characters in http.server.BaseHTTPRequestHandler.log_message with an escaped \xHH sequence to avoid causing problems for the terminal the output is printed to.
(cherry picked from commit d8ab0a4dfa)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
In case if only True/False be supported as boolean arguments in future,
we should continue to support 1/0 here.
(cherry picked from commit 922a6cf6c2)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Skip test_normalization() of test_unicodedata if it fails to download
NormalizationTest.txt file from pythontest.net.
(cherry picked from commit 2488c1e1b6)
Co-authored-by: Victor Stinner <vstinner@python.org>
On FreeBSD, skip test_script_as_dev_fd() of test_cmd_line_script if
fdescfs is not mounted (at /dev/fd).
(cherry picked from commit 038b151963)
Co-authored-by: Victor Stinner <vstinner@python.org>
Existing elements do produce different output on x86_64, but they
do not on x86. Let's make the data longer to ensure it differs.
(cherry picked from commit c68573b339)
Co-authored-by: Alexander Kanavin <alex.kanavin@gmail.com>
(cherry picked from commit 367f552129)
Co-authored-by: Christoph Anton Mitterer <calestyo@scientia.org>
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Fixes private checks for network objects. The previous method would incorrectly return True for a private check in cases such as "0.0.0.0/0".
(cherry picked from commit ed391090cc)
Co-authored-by: Pete Wicken <2273100+JamoBox@users.noreply.github.com>
* Fix substitution of TypeVarTuple and ParamSpec together in user generics.
* Fix substitution of ParamSpec followed by TypeVarTuple in generic aliases.
* Check the number of arguments in substitution in user generics containing a
TypeVarTuple and one or more TypeVar.
(cherry picked from commit 8f2fb7dfe7)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
On macOS all file descriptors for a particular file in /dev/fd
share the same file offset, that is ``open("/dev/fd/9", "r")`` behaves
more like ``dup(9)`` than a regular open.
This causes problems when a user tries to run "/dev/fd/9" as a script
because zipimport changes the file offset to try to read a zipfile
directory. Therefore change zipimport to reset the file offset after
trying to read the zipfile directory.
(cherry picked from commit d08fb25769)
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
The tests in question were added in 0eec6276fd by Serhiy. Apparently,
sqlite3 changed exceptions raised in those cases in the mean time but
the tests never ran because they require a high `-M` setting in the
test runner.
(cherry picked from commit 2781ec9b0e)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
[3.11] gh-99103: Normalize specialized traceback anchors against the current line (GH-99145)
Automerge-Triggered-By: GH:isidentical.
(cherry picked from commit 57be545959)
Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
Fix a reference bug in _imp.create_builtin() after the creation of
the first sub-interpreter for modules "builtins" and "sys".
(cherry picked from commit cb2ef8b2ac)
Co-authored-by: Victor Stinner <vstinner@python.org>
When build with shared enabled, we need to set `LD_LIBRARY_PATH`
for the non-installed python environment in
test_zippath_from_non_installed_posix so that the python binary
and find and link the libpython.so.
(cherry picked from commit 1df0752b4d)
Co-authored-by: Kai Zhang <kylerzhang11@gmail.com>
Before python3.11, when in a venv the zip path is calculated
from prefix on POSIX platforms. In python3.11 the behavior is
accidentally changed to calculating from default prefix. This
change will break venv created from a non-installed python
with a stdlib zip file. This commit restores the behavior back
to before python3.11.
(cherry picked from commit e3d4fed074)
Co-authored-by: Kai Zhang <kylerzhang11@gmail.com>
Prevent urllib.parse.urlparse from accepting schemes that don't begin with an alphabetical ASCII character.
RFC 3986 defines a scheme like this: `scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )`
RFC 2234 defines an ALPHA like this: `ALPHA = %x41-5A / %x61-7A`
The WHATWG URL spec defines a scheme like this:
`"A URL-scheme string must be one ASCII alpha, followed by zero or more of ASCII alphanumeric, U+002B (+), U+002D (-), and U+002E (.)."`
(cherry picked from commit 439b9cfaf4)
Co-authored-by: Ben Kallus <49924171+kenballus@users.noreply.github.com>
Check to see if `base_executable` exists. If it does not, attempt
to use known alternative names of the python binary to find an
executable in the path specified by `home`.
If no alternative is found, previous behavior is preserved.
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
(cherry picked from commit c41b13d39c)
Co-authored-by: Vincent Fazio <vfazio@gmail.com>
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
[Enum] fix negative number infinite loop
- _iter_bits_lsb() now raises a ValueError if a negative number
is passed in
- verify() now skips checking negative numbers for named flags
(cherry picked from commit 0b4ffb08cc)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
There was an unnecessary quadratic loop in idna decoding. This restores
the behavior to linear.
(cherry picked from commit d315722564)
Co-authored-by: Gregory P. Smith <greg@krypto.org>
* fix auto() failure during multiple assignment
i.e. `ONE = auto(), 'text'` will now have `ONE' with the value of `(1,
'text')`. Before it would have been `(<an auto instance>, 'text')`
(cherry picked from commit 8feb7ab77c)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
The test.support.wait_process() function now uses a timeout of
LONG_TIMEOUT seconds by default, instead of SHORT_TIMEOUT. It
doesn't matter if a Python buildbot is slower, it only matters that
the process completes. The timeout should just be shorter than
"forever".
(cherry picked from commit f09da28768)
In very rare circumstances the JUMP opcode could be confused with the
argument of the opcode in the "then" part which doesn't end with the
JUMP opcode. This led to incorrect detection of the final JUMP opcode
and incorrect calculation of the size of the subexpression.
NOTE: Changed return value of functions _validate_inner() and
_validate_charset() in Modules/_sre/sre.c. Now they return 0 on success,
-1 on failure, and 1 if the last op is JUMP (which usually is a failure).
Previously they returned 1 on success and 0 on failure.
(cherry picked from commit e9ac890c02)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-98925: Lower marshal recursion depth for WASI (GH-98938)
For wasmtime 2.0, the stack depth cost is 6% higher. This causes the default max `marshal` recursion depth to blow the stack.
As the default marshal depth is 2000 and Windows is set to 1000, split the difference and choose 1500 for WASI to be safe.
(cherry picked from commit 9711265182)
Co-authored-by: Brett Cannon <brett@python.org>
Fix subscription of type aliases containing bare generic types or types
like TypeVar: for example tuple[A, T][int] and tuple[TypeVar, T][int],
where A is a generic type, and T is a type variable.
(cherry picked from commit 0e15c31c7e)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-96151: Use a private name for passing builtins to dataclass. This now allows for a field named BUILTIN (gh-98143)
(cherry picked from commit 29f98b46b7)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* As most of `test_embed` now uses `Py_InitializeFromConfig`, add
a specific test case to cover `Py_Initialize` (and `Py_InitializeEx`)
* Rename `_testembed` init helper to clarify the API used
* Add a `PyConfig_Clear` call in `Py_InitializeEx` to make
the code more obviously correct (it already didn't leak as
none of the dynamically allocated config fields were being
populated, but it's clearer if the wrappers follow the
documented API usage guidelines)
(cherry picked from commit 05e48865be)
Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
* gh-98783: Fix crashes when `str` subclasses are used in `_PyUnicode_Equal` (GH-98806)
(cherry picked from commit 76f989dc3e)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>.
Co-authored-by: Matthew Rahtz <matthew.rahtz@gmail.com>
(cherry picked from commit cb95cc24ef)
When merging the v3.11.0 tag into 3.11, some files were incorrectly updated and some others were not properly deleted.
Automerge-Triggered-By: GH:pablogsal
Reason: we were too hasty in deprecating this.
We shouldn't deprecate it before we have a replacement.
(cherry picked from commit 09de8d7aaf)
Co-authored-by: Guido van Rossum <guido@python.org>
On Windows, when the Python test suite is run with the -jN option,
the ANSI code page is now used as the encoding for the stdout
temporary file, rather than using UTF-8 which can lead to decoding
errors.
(cherry picked from commit ec1f6f5f13)
Co-authored-by: Victor Stinner <vstinner@python.org>
Fix multiplying a list by an integer (list *= int): detect the
integer overflow when the new allocated length is close to the
maximum size. Issue reported by Jordan Limor.
list_resize() now checks for integer overflow before multiplying the
new allocated length by the list item size (sizeof(PyObject*)).
(cherry picked from commit a5f092f3c4)
Co-authored-by: Victor Stinner <vstinner@python.org>
The main problem was that an unluckily timed task cancellation could cause
the semaphore to be stuck. There were also doubts about strict FIFO ordering
of tasks allowed to pass.
The Semaphore implementation was rewritten to be more similar to Lock.
Many tests for edge cases (including cancellation) were added.
(cherry picked from commit 24e0379624)
Co-authored-by: Cyker Way <cykerway@gmail.com>
Fix command line parsing: reject "-X int_max_str_digits" option with
no value (invalid) when the PYTHONINTMAXSTRDIGITS environment
variable is set to a valid limit.
(cherry picked from commit 41351662bc)
Co-authored-by: Victor Stinner <vstinner@python.org>