gh-143916: Reject control characters in wsgiref.headers.Headers (GH-143917)
* Add 'test.support' fixture for C0 control characters
* gh-143916: Reject control characters in wsgiref.headers.Headers
(cherry picked from commit f7fceed79ca1bceae8dbe5ba5bc8928564da7211)
Co-authored-by: Seth Michael Larson <seth@python.org>
gh-143641: Make `ready_to_import` always remove tempdir from `sys.path` (GH-143642)
Make ready_to_import always remove tempdir from sys.path
(cherry picked from commit e7f5ffa0de2476828d78b8d39caefc38d797c206)
Co-authored-by: Jeong, YunWon <69878+youknowone@users.noreply.github.com>
For example, "-u xpickle=2.7" will run test_xpickle only against Python 2.7.
(cherry picked from commit c07e5ec0a9e5843fc39dec6aa94172faf6354858)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-142353: Isolate tests from personal GNU Readline init files (GH-142370)
Isolate tests from personal Readline init files using `INPUTRC=/dev/null` trick.
(cherry picked from commit f564654bae79c69e3de40dadbec2399f1423ffcf)
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-139310: skip `test_aead_aes_gcm` for Linux kernel between 6.16.0 and 6.17.x (GH-139552)
Currently, Fedora 42 uses a custom Linux Kernel 6.16.9 that backported an upstream change
from 6.17-rc7 [1,3] but not its subsequent fix [2]. Until the issue is resolved upstream,
we skip the failing test `test_socket.test_aead_aes_gcm` for kernel versions between 6.16
and 6.17.x.
[1] 1b34cbbf4f
[2] d0ca0df179
[3] 45bcf60fe4
(cherry picked from commit 41712c4e095b2cc988febfe3887616c2779c6210)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Previous error message suggested to use cls.__new__(), which
obviously does not work. Now the error message is the same as for
cls(...).
(cherry picked from commit c45f4f3ebe34529a8db3a7918e8dd2e9f7ce8e86)
gh-133167: Fix compilation process with `--enable-optimizations` and `--without-docstrings` (GH-133187)
(cherry picked from commit cc39b19f0fca8db0f881ecaf02f88d72d9f93776)
Co-authored-by: sobolevn <mail@sobolevn.me>
gh-132415: Use shutil.which() in missing_compiler_executable() (GH-132906)
Replace deprecated distutils.spawn.find_executable() with
shutil.which() in missing_compiler_executable() of test.support.
(cherry picked from commit de6482eda3a46cc9c9a03fb9ba57295ab99b4722)
Co-authored-by: Victor Stinner <vstinner@python.org>
Modifies the test helper that counts the list of open file descriptors to use
the optimised ``/dev/fd`` approach on all Apple platforms, not just macOS. This
avoids crashes caused by guarded file descriptors.
(cherry picked from commit 862fd890361005598a6f4614ea0608c8447831c2)
Co-authored-by: John <johnzhou721@gmail.com>
gh-132316: Require `socket` and `GITHUB_TOKEN` env to use `GitHubArtifactDatabase` (GH-132348)
(cherry picked from commit fcf2d07228ada64bc864380cd8e3e304d9768caa)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
CI: set correct working directory for Hypothesis cache (GH-119345)
Set cwd for Hypothesis database
(cherry picked from commit 055c739536ad63b55ad7cd0b91ccacc33064fe11)
Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
(cherry picked from commit 3185e3115c918ec189e16cf9f5b51a13a0146556)
---------
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
gh-131032: Add support.linked_to_musl() function (#131071)
Skip test_math.test_fma_zero_result() if Python is linked to the musl
C library.
(cherry picked from commit 68922ace4dabb6635e6d5b51bbe6485ef2e9dad2)
GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550)
(cherry picked from commit 129db32d6f2d7f450d2741da6a222c18e458c61b)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Add a mix-in class ExtraAssertions containing the following methods:
* assertHasAttr() and assertNotHasAttr()
* assertIsSubclass() and assertNotIsSubclass()
* assertStartsWith() and assertNotStartsWith()
* assertEndsWith() and assertNotEndsWith()
(cherry picked from commit 06cad77a5b345adde88609be9c3c470c5cd9f417)
Run them with different locales and different date and time.
Add the @run_with_locales() decorator to run the test with multiple
locales.
Improve the run_with_locale() context manager/decorator -- it now
catches only expected exceptions and reports the test as skipped if no
appropriate locale is available.
(cherry picked from commit 19984fe024bfd90649f1c36b78c9abf3ed72b27d)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
For source file "path/to/file.py" it created file with incorrect path
"/absolute/path/to/path/to/file.pyc" instead of "path/to/file.pyc".
(cherry picked from commit 60ff67d010078eca15a74b1429caf779ac4f9c74)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Detect source file encoding.
* Use the "replace" error handler even for UTF-8 (default) encoding.
* Remove the BOM.
* Fix detection of too long lines if they contain NUL.
* Return the head rather than the tail for truncated long lines.
(cherry picked from commit e2f710792b0418b8ca1ca3b8cdf39588c7268495)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-101525: Skip test_gdb if the binary is relocated by BOLT. (gh-118572)
(cherry picked from commit f95fc4de115ae03d7aa6dece678240df085cb4f6)
Co-authored-by: Donghee Na <donghee.na@python.org>
The tests were only checking cases where the slot wrapper was present in the initial case. They were missing when the slot wrapper was added in the additional initializations. This fixes that.
(cherry-picked from commit 490e0ad83ac72c5688dfbbab4eac61ccfd7be5fd, AKA gh-122248)
See 6b98b274b6 for an explanation of the problem and solution. Here I've applied the solution to channels.
(cherry picked from commit 8b209fd4f8a9bf9603888bda2c44b5cfd4ebf47a, AKA gh-121805)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Any cross-interpreter mechanism for passing objects between interpreters must be very careful to respect isolation, even when the object is effectively immutable (e.g. int, str). Here this especially relates to when an interpreter sends one of its objects, and then is destroyed while the inter-interpreter machinery (e.g. queue) still holds a reference to the object.
When I added interpreters.Queue, I dealt with that case (using an atexit hook) by silently removing all items from the queue that were added by the finalizing interpreter.
Later, while working on concurrent.futures.InterpreterPoolExecutor (gh-116430), I noticed it was somewhat surprising when items were silently removed from the queue when the originating interpreter was destroyed. (See my comment on that PR.)
It took me a little while to realize what was going on. I expect that users, which much less context than I have, would experience the same pain.
My approach, here, to improving the situation is to give users three options:
1. return a singleton (interpreters.queues.UNBOUND) from Queue.get() in place of each removed item
2. raise an exception (interpreters.queues.ItemInterpreterDestroyed) from Queue.get() in place of each removed item
3. existing behavior: silently remove each item (i.e. Queue.get() skips each one)
The default will now be (1), but users can still explicitly opt in any of them, including to the silent removal behavior.
The behavior for each item may be set with the corresponding Queue.put() call. and a queue-wide default may be set when the queue is created. (This is the same as I did for "synconly".)
(cherry picked from commit 6b98b274b60a15b490d2ea85069638c037b2a9cd, AKA gh-116431)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
gh-121571: Do not use `EnvironmentError` in tests, use `OSError` instead (GH-121572)
(cherry picked from commit e2822360da30853f092d8a50ad83e52f6ea2ced9)
Co-authored-by: sobolevn <mail@sobolevn.me>
Check if the DateTime C-API type matches the datetime.date type on main and shared/isolated subinterpreters.
(cherry picked from commit 50a389565aa0b480792ed06a2ab56fb5a72fc2d8, AKA gh-119604)
Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
The free-threaded build currently immortalizes objects that use deferred
reference counting (see gh-117783). This typically happens once the
first non-main thread is created, but the behavior can be suppressed for
tests, in subinterpreters, or during a compile() call.
This fixes a race condition involving the tracking of whether the
behavior is suppressed.
(cherry picked from commit 47fb4327b5c405da6df066dcaa01b7c1aefab313)
We already intern and immortalize most string constants. In the
free-threaded build, other constants can be a source of reference count
contention because they are shared by all threads running the same code
objects.