Commit Graph

33527 Commits

Author SHA1 Message Date
Irit Katriel ffc2f1dd1c
gh-130080: implement PEP 765 (#130087) 2025-03-17 20:48:54 +00:00
R. David Murray a09c2b2ba6
Fix test_pyrepl.TestDumbTerminal if PYTHON_BASIC_REPL set. (#131332)
Most of the tests that care already adjust PYTHON_BASIC_REPL as needed,
but this one doesn't, and it fails if the developer has the variable set.
2025-03-17 18:56:21 +01:00
Mark Shannon 9881fc5483
GH-125174: Make immortality "sticky" (GH-131355)
* Use a higher threshold for immortality for INCREF than DECREF
2025-03-17 17:22:35 +00:00
Tomasz Pytel 863d54cbaf
gh-126895: Fix readline module in free-threaded build (#131208)
The underlying readline library is not thread-safe so this adds `@critical_section` to functions that use it.
2025-03-17 11:57:11 -04:00
Bénédikt Tran de8890f5ab
gh-130149: cleanup refactorization of `test_hmac.py` (#131318)
New features:

* refactor `hashlib_helper.requires_hashdigest` in prevision of a future
  `hashlib_helper.requires_builtin_hashdigest` for built-in hashes only
* add `hashlib_helper.requires_openssl_hashdigest` to request OpenSSL
   hashes, assuming that `_hashlib` exists.

Refactoring:

* split hmac.copy() test by implementation
* update how algorithms are discovered for RFC test cases
* simplify how OpenSSL hash digests are requested
* refactor hexdigest tests for RFC test vectors
* typo fix: `assert_hmac_hexdigest_by_new` -> `assert_hmac_hexdigest_by_name`

Improvements:

* strengthen contract on `hmac_new_by_name` and `hmac_digest_by_name`
* rename mixin classes to better match their responsibility
2025-03-17 11:10:03 +01:00
Nybblista 3ae67ba97e
gh-131339: test PyBytes_Size for a zero-size bytes object (#131340) 2025-03-17 11:38:37 +03:00
Hood Chatham cf288e3c25
gh-127146: Update test skips for Emscripten 4.0.2 (#129474)
Updates test skips to reflect capabilities of Emscripten 4.0.2.
2025-03-17 06:02:27 +08:00
Tomas R. d07e9ebbe8
gh-131306: Remove unused code related to `BINARY_SUBSCR` (#131307) 2025-03-16 16:37:29 +00:00
Bénédikt Tran 9b6cef0f5d
gh-131254: ensure that `BROWSER` is not set for `test_webbrowser` on macOS (#131276) 2025-03-16 15:39:30 +01:00
Bénédikt Tran 3185e3115c
gh-131277: allow `EnvironmentVarGuard` to unset more than one environment variable at once (#131280)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-16 14:09:33 +01:00
Yan Yanchii 55815a6474
gh-130480: Move duplicate `LOAD_SMALL_INT` optimization from codegen to CFG (#130481) 2025-03-14 21:23:27 +00:00
Tian Gao 26511993e6
gh-121468: Fix the doctest failure for asyncio test on pdb (#131258) 2025-03-14 16:23:21 -04:00
Barney Gale 633942e348
GH-130614: pathlib ABCs: delete vestigial `test_pathlib_abc` module (#131215)
Remove the `test.test_pathlib.test_pathlib_abc` test module, which was
hollowed out in previous commits. Its few remaining tests are most relevant
to `PurePath` and `Path`, so we move them into `test_pathlib`.
2025-03-14 20:04:07 +00:00
Tian Gao 27fc62cf4f
gh-121468: Add current asyncio task as a convenience variable in pdb (#124367) 2025-03-14 14:46:26 -04:00
sobolevn fc07f863ee
gh-131234: Improve `test_popen` with more asserts (#131235) 2025-03-14 11:38:31 +00:00
Mark Shannon 2250ab6a13
GH-125174 Revert: Make immortality "sticky" (GH-131184)" (#131230)
Revert "GH-125174: Make immortality "sticky" (GH-131184)"

This reverts commit 3a91ee9724.
2025-03-14 13:13:47 +02:00
Wulian233 7fd61607cd
gh-131204: Fix `difflib.HtmlDiff` may not use monospaced font (#131221)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-14 10:45:33 +00:00
sobolevn f6c24a5c89
gh-131219: Improve tests in `test_lzma.py` by adding more asserts (#131220) 2025-03-14 10:16:50 +00:00
Min RK 96492785b2
gh-128540: lookup default webbrowser on macOS (#130535)
Ensure web browser is launched by `webbrowser.open` on macOS, even for `file://` URLs.
2025-03-14 02:51:15 -04:00
Barney Gale 45c2ef48ca
GH-130614: pathlib ABCs: parametrize test suite for path copying (#131168)
Test copying from `Path` and `ReadableZipPath` (types of `_ReadablePath`)
to `Path` and `WritableZipPath` (types of `_WritablePath`).
2025-03-13 21:56:59 +00:00
sobolevn 1a8e5742cd
Remove `print` from `test_monitoring.py` (#131200) 2025-03-13 22:54:17 +03:00
Pieter Eendebak ec46a55d63
gh-121464: Make concurrent iteration over enumerate safe under free-threading (#125734) 2025-03-14 00:14:05 +05:30
Tomas R. 7ea6e88eb4
gh-85012: Properly reset msgctxt when compiling messages with msgfmt (GH-130525)
Add also human-readable snapshots for tests.
2025-03-13 20:40:40 +02:00
Tomasz Pytel c5abded099
gh-130382: add missing `_PyReftracerTrack` to ceval `Py_DECREF` (#130689) 2025-03-13 12:31:49 -04:00
Mark Shannon 3a91ee9724
GH-125174: Make immortality "sticky" (GH-131184) 2025-03-13 16:10:13 +00:00
Victor Stinner 10cbd1fe88
gh-130947: Add again PySequence_Fast() to the limited C API (#130948)
Add again PySequence_Fast() to the limited C API.

Add unit tests.
2025-03-13 13:00:57 +01:00
Oleg Iarygin 328f8b8856
gh-93096: Make `mimetypes` CLI tool public (#93097)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-03-13 13:19:22 +02:00
Chris Eibl 119bcfad9c
gh-129149: Add fast path for medium-sized integers in `PyLong_FromSsize_t()` (#129301)
The implementation of `PyLong_FromLong()`, `PyLong_FromLongLong()` and `PyLong_FromSsize_t()`
are now handled by a common macro `PYLONG_FROM_INT` which contains fast paths depending on the
size of the integer to convert. Consequently, `PyLong_FromSsize_t()` for medium-sized integers is faster
by roughly 25%.

---------

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-03-13 12:06:56 +01:00
Enzo Bonnal a005835f69
gh-74028: add `buffersize` parameter to `concurrent.futures.Executor.map` for lazier behavior (#125663)
`concurrent.futures.Executor.map` now supports limiting the number of submitted
tasks whose results have not yet been yielded via the new `buffersize` parameter.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-03-13 11:57:53 +01:00
Cody Maloney 93089c0736
gh-130806: Emit ResourceWarning if GzipFile unclosed (#130905)
This may indicate accidental data loss.

Ways to make sure all data is written:
1. Use the [file-like object](https://docs.python.org/3/glossary.html#term-file-object) as a [“With Statement Context Manager”](https://docs.python.org/3/reference/datamodel.html#context-managers).
   - All objects which [inherit](https://docs.python.org/3/tutorial/classes.html#inheritance) from [IOBase](https://docs.python.org/3/library/io.html#io.IOBase) support this.
   - [`BufferedIOBase`](https://docs.python.org/3/library/io.html#io.BufferedIOBase), [`BufferedWriter`](https://docs.python.org/3/library/io.html#io.BufferedWriter), and [`GzipFile`](https://docs.python.org/3/library/gzip.html#gzip.GzipFile) all support this.
   - Ensures `.close()` is called in both exception and regular cases.

2. Ensure [`.close()`](https://docs.python.org/3/library/io.html#io.IOBase.close) is always called which flushes data before closing.

3. If the underlying stream need to be kept open, use [`.detach()`](https://docs.python.org/3/library/io.html#io.BufferedIOBase.detach)

Since 3.12 flushing has been necessary in GzipFile (see gh-105808 which was a release blocker), this makes that more visible. Users have been encountering as they upgrade to 3.12 (ex. gh-129726).

There are a number of cases of unclosed file-like objects being deleted in CPython libraries and the test suite. This issue includes resolving those cases where the new ResourceWarning is emitted.

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-13 11:20:05 +01:00
Victor Stinner b2ca26875a
gh-131152: Remove unused imports from tests (part 2) (#131154) 2025-03-13 10:57:40 +01:00
Victor Stinner 73ab9e2ede
gh-131152: Remove unused imports from tests (#131153) 2025-03-13 10:55:23 +01:00
Victor Stinner 68922ace4d
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.
2025-03-13 10:33:46 +01:00
Victor Stinner 2ed671b5e3
gh-111178: Change Argument Clinic signature for `@staticmethod` (#131157) (#131159)
Use "PyObject*", instead of "void*", for `@staticmethod` functions to
fix an undefined behavior.
2025-03-13 10:22:58 +01:00
Hood Chatham db1e5827c4
gh-127503: Improve tracebacks on Emscripten when there is a trap (#131158)
Modifies the behavior of the interpreter on crash under Emscripten:
1. No Python traceback shown on segfault/trap
2. The JavaScript source line is shown

The JavaScript source line is super long and completely unenlightening,
whereas the Python traceback is very helpful.
2025-03-13 08:28:15 +08:00
Tian Gao b52866953a
gh-131123: Support completion in `pdb` for convenience variable attributes (#131124) 2025-03-12 17:23:53 -04:00
Ethan Furman 17d06aeb54
gh-131045: [Enum] fix flag containment checks when using values (GH-131053)
Check would fail if value would create a pseudo-member, but that member
had not yet been created.  We now attempt to create a pseudo-member for
a passed-in value first.

Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-03-12 12:10:47 -07:00
Barney Gale db6a998b18
GH-130614: pathlib ABCs: revise test suite for writable paths (#131112)
Test `pathlib.types._WritablePath` in a dedicated test module. These tests
cover `WritableZipPath`, `WritableLocalPath` and `Path`, where the former
two classes are implementations of `_WritablePath` for use in tests.
2025-03-12 19:06:43 +00:00
Sam Gross 776ec1e167
gh-110097: Fix flaky `test_timeout` in `test_concurrent_futures.test_process_pool` (gh-131108)
On heavily loaded systems, the launch of the workers to run
`time.sleep(0)` can take longer than the five second timeout.
2025-03-12 13:16:23 -04:00
Victor Stinner 061da44bac
gh-111178: Change Argument Clinic signature for `@classmethod` (#131157)
Use "PyObject*", instead of "PyTypeObject*", for `@classmethod`
functions to fix an undefined behavior.
2025-03-12 17:42:07 +01:00
T. Wouters de2f7da77d
gh-115999: Add free-threaded specialization for FOR_ITER (#128798)
Add free-threaded versions of existing specialization for FOR_ITER (list, tuples, fast range iterators and generators), without significantly affecting their thread-safety. (Iterating over shared lists/tuples/ranges should be fine like before. Reusing iterators between threads is not fine, like before. Sharing generators between threads is a recipe for significant crashes, like before.)
2025-03-12 16:21:46 +01:00
Pieter Eendebak 1fb7e2aeb7
gh-120608: Make reversed iterator work with free-threading (#120971)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-03-12 12:39:52 +01:00
Daniel Pope e0637cebe5
gh-129349: Accept bytes in bytes.fromhex()/bytearray.fromhex() (#129844)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-12 11:40:11 +01:00
Pieter Eendebak 405a2d74cb
gh-123471: make `itertools.batched` thread-safe (#129416) 2025-03-12 15:30:33 +05:30
Stan Ulbrych 155c44b901
gh-81267: Correct time.sleep() error message (#131055) 2025-03-12 08:12:57 +00:00
donBarbos 15a8412b5e
gh-93096: Load doctests in `test_itertools` (#131133) 2025-03-12 08:40:59 +01:00
Sergey B Kirpichev 52756c30db
Use subTest() in math.fma() tests (#131125) 2025-03-12 07:22:28 +01:00
Pablo Galindo Salgado ebc24d54bc
gh-117174: Fix reference leak and gdb tests (#131095) 2025-03-11 23:17:58 +00:00
Barney Gale ad90c5fabc
GH-130614: pathlib ABCs: revise test suite for readable paths (#131018)
Test `pathlib.types._ReadablePath` in a dedicated test module. These tests
cover `ReadableZipPath`, `ReadableLocalPath` and `Path`, where the former
two classes are implementations of `_ReadablePath` for use in tests.
2025-03-11 20:54:22 +00:00
Kumar Aditya 24070492cf
gh-128002: add `test_asyncio.test_free_threading` to tsan tests (#131106) 2025-03-12 01:33:44 +05:30
Kumar Aditya fcf756adef
fix various warnings in `test_asyncio.test_tasks` (#131109) 2025-03-11 19:51:53 +00:00
Tian Gao 8b1edae93a
gh-122029: Do not unpack method for legacy tracing anymore (#130898) 2025-03-11 14:04:22 -04:00
Barney Gale 3569e4a670
GH-130614: pathlib ABCs: revise test suite for Windows path joining (#131016)
Test Windows-flavoured `pathlib.types._JoinablePath` in a dedicated test
module. These tests cover `LexicalWindowsPath`, `PureWindowsPath` and
`WindowsPath`, where `LexicalWindowsPath` is a simple implementation of
`_JoinablePath` for use in tests.
2025-03-11 18:01:43 +00:00
Victor Stinner 9d759b63d8
gh-111178: Change Argument Clinic signature for METH_O (#130682)
Use "PyObject*" for METH_O functions to fix an undefined behavior.
2025-03-11 16:33:36 +01:00
Sam Gross 1908115871
gh-130957: Use `sleeping_retry` in `test_free_reference` (#130958)
The weak reference may not be immediately dead.
2025-03-11 09:51:26 -04:00
donBarbos 3bb20d13a8
gh-93096: Load doctests in `test_pickle` (#131069)
Add doctests to unittest for `pickle`
2025-03-11 12:25:25 +02:00
Michał Górny 33494b4d0d
gh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()` (#130962)
* gh-130959: Reject whitespace in fractions, in pure Python `fromisoformat()`

Fix the pure Python implementation of `fromisoformat()` to reject any
non-digit characters, including whitespace, in the fractional part
of time specification.  This makes the behavior consistent with the C
implementation, and prevents incorrect parsing of these fractions
(e.g. `.400 ` would be misinterpreted as `.04`).

* Add the news entry

* Use a different example to fix Sphinx lint

* Apply suggestions from code review

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>

* Try fixing `:func:` ref.

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2025-03-11 10:15:40 +01:00
Jakub Kulík 69309a55bc
gh-130932: cwd cannot be removed on Solaris/Illumos (#131037) 2025-03-11 10:09:04 +01:00
Pablo Galindo Salgado 4192ce17ba
gh-117174: Adapt test_multiple_statements_fail_early now that we have always source (#131065) 2025-03-10 23:10:53 +00:00
Sergey Miryanov 7c98b0674d
gh-130804: Fix support of typing unicode chars in pyrepl (#130805) 2025-03-10 22:13:50 +00:00
FeH2 6ab5c4aa05
gh-124927: Fix conversion issue between coordinates and position in REPL (#125001) 2025-03-10 21:54:49 +00:00
Pablo Galindo Salgado a931a8b324
gh-117174: Add a new route in linecache to fetch interactive source code (#117500) 2025-03-10 21:54:05 +00:00
Pablo Galindo Salgado fd3b49e85d
gh-128515: Properly check for bolt in test_perf_profiler (#131058) 2025-03-10 21:48:03 +00:00
Chris Eibl 36ef3bfe39
gh-131020: py.exe launcher does not correctly detect a BOM when searching for the shebang (GH-131021) 2025-03-10 17:59:23 +00:00
Barney Gale 5a484714c3
GH-130614: pathlib ABCs: revise test suite for Posix path joining (#131017)
Test Posix-flavoured `pathlib.types._JoinablePath` in a dedicated test
module. These tests cover `LexicalPosixPath`, `PurePosixPath` and
`PosixPath`, where `LexicalPosixPath` is a simple implementation of
`_JoinablePath` for use in tests.
2025-03-10 17:59:10 +00:00
Barney Gale 93fc3d34f9
GH-127381: pathlib ABCs: remove `case_sensitive` argument (#131024)
Remove the *case_sensitive* argument from `_JoinablePath.full_match()` and
`_ReadablePath.glob()`. Using a non-native case sensitivity forces the use
of "case-pedantic" globbing, where we `iterdir()` even for non-wildcard
pattern segments. But it's hard to know when to enable this mode, as
case-sensitivity can vary by directory, so `_PathParser.normcase()` doesn't
always give the full picture. The `Path.glob()` implementation is forced to
make an educated guess, but we can avoid the issue in the ABCs by dropping
the *case_sensitive* argument.

(I probably shouldn't have added these arguments in `PurePath` and `Path`
in the first place!)

Also drop support for `_ReadablePath.glob(recurse_symlinks=False)`, which
makes recursive globbing much slower.
2025-03-10 17:50:48 +00:00
Mark Shannon be046ee6e0
GH-123044: Give the `POP_TOP` after a case test a location in the body, not the pattern. (GH-130627) 2025-03-10 17:31:16 +00:00
Mark Shannon 2bef8ea8ea
GH-127705: Use `_PyStackRef`s in the default build. (GH-127875) 2025-03-10 14:06:56 +00:00
Barney Gale 475f933ed8
GH-130614: pathlib ABCs: revise test suite for path joining (#130988)
Test `pathlib.types._JoinablePath` in a dedicated test module. These tests
cover `LexicalPath`, `PurePath` and `Path`, where `LexicalPath` is defined
in a new `test.test_pathlib.support` package.
2025-03-09 17:02:37 +00:00
Sam Gross edd1eca336
gh-130954: Fix multiprocessing test_notify_n (#130955)
The test could deadlock trying join on the worker processes.
Apply the same technique as gh-130933.

Join the process before the test ends in `test_notify` as well.
2025-03-08 13:04:30 -05:00
Chris Markiewicz 72e5b25efb
gh-128646: Implement GzipFile.readinto[1]() methods (GH-128647)
The new methods simply delegate to the underlying buffer, much like the existing GzipFile.read[1] methods.  This avoids extra allocations caused by the BufferedIOBase.readinto implementation previously used.

This commit also factors out a common readability check rather than copying it an additional two times.
2025-03-07 21:04:45 -06:00
Diego Russo 7879081198
gh-130917: update timer and workload in test_signal (#130918)
The workload to advance the virtual timeout is too lightweight for some
platforms. As result the test goes in timeout as it never reaches the
end of the timer. By having a heavier workload, the virtual timer
advances rapidly and the SIGVTALRM is sent before the timeout.
2025-03-07 16:10:02 -05:00
morotti b1b4f9625c
gh-117151: IO performance improvement, increase io.DEFAULT_BUFFER_SIZE to 128k (GH-118144)
Co-authored-by: rmorotti <romain.morotti@man.com>
2025-03-07 11:36:12 -08:00
Sam Gross c476410dc5
gh-110206: Fix multiprocessing test_notify_all (#130933)
The test could deadlock trying join on the worker processes due to a
combination of behaviors:

* The use of `assertReachesEventually` did not ensure that workers
  actually woken.release() because the SyncManager's Semaphore does not
  implement get_value.

* This mean that the test could finish and the variable "sleeping" would
  got out of scope and be collected. This unregisters the proxy leading
  to failures in the worker or possibly the manager.

* The subsequent call to `p.join()` during cleanUp therefore never
  finished.

This takes two approaches to fix this:

1) Use woken.acquire() to ensure that the workers actually finish
   calling woken.release()

2) At the end of the test, wait until the workers are finished, while `cond`,
   `sleeping`, and `woken` are still valid.
2025-03-07 09:58:09 -05:00
Mark Shannon 89df62c120
GH-128534: Fix behavior of branch monitoring for `async for` (GH-130847)
* Both branches in a pair now have a common source and are included in co_branches
2025-03-07 14:30:31 +00:00
Shantanu 0a9ae5ed48
gh-130932: Fix incorrect exception handling in _PyModule_IsPossiblyShadowing (#130934)
I chose to not raise an exception here because I think it would be
confusing for module attribute access to start raising something other
than AttributeError if e.g. the cwd goes away

Without the change in moduleobject.c
```
./python.exe -m unittest test.test_import.ImportTests.test_script_shadowing_stdlib_cwd_failure
...
Assertion failed: (PyErr_Occurred()), function _PyObject_SetAttributeErrorContext, file object.c, line 1253.
```
2025-03-06 23:41:28 -08:00
Sam Gross a025f27d94
gh-130920: Fix data race in STORE_SUBSCR_LIST_INT (#130923)
The write of the item to the list needs to use an atomic operation in
the free threading build.

Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
2025-03-06 15:59:48 -05:00
mpage 6c6600f683
gh-118331: Fix `test_list.ListTest.test_no_memory` under trace refs build (#130921)
Fix `test_list.ListTest.test_no_memory` under trace refs build

Memory allocation ends up failing in _PyRefchainTrace(), which produces
different output. Assert that we don't segfault, which is the thing
we want to test and is less brittle than checking output.
2025-03-06 12:11:50 -08:00
Sam Gross c4d37eefb7
gh-128364: Fix flaky `test_concurrent_futures.test_wait` tests (gh-130742)
Use events instead of relying on `time.sleep()`. The tests are also now about
four times faster.
2025-03-06 12:30:58 -05:00
Sebastian Rittau c6dd2348ca
gh-127647: Add typing.Reader and Writer protocols (#127648) 2025-03-06 07:36:19 -08:00
Sergey B Kirpichev 2352bd418a
gh-130860: Fix width calculation, when separators in fractional part (GH-130865)
This amends f39a07be47
2025-03-06 14:26:29 +02:00
Tomasz Pytel aeb2327386
gh-130574: renumber RESUME opcode from 149 to 128 (GH-130685) 2025-03-06 08:59:36 +00:00
Bartosz Sławecki 293fa3433e
gh-85795: Raise a clear error when `super()` is used in `typing.NamedTuple` subclasses (#130082) 2025-03-05 20:45:47 -08:00
Charles Machalow ba05a4ebcb
gh-128041: Add `terminate_workers` and `kill_workers` methods to ProcessPoolExecutor (GH-130849)
This adds two new methods to `multiprocessing`'s `ProcessPoolExecutor`:
- **`terminate_workers()`**: forcefully terminates worker processes using `Process.terminate()`
- **`kill_workers()`**: forcefully kills worker processes using `Process.kill()`

These methods provide users with a direct way to stop worker processes without `shutdown()` or relying on implementation details, addressing situations where immediate termination is needed.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Sam Gross @colesbury
Commit-message-mostly-authored-by: Claude Sonnet 3.7 (because why not -greg)
2025-03-05 14:31:42 -08:00
mpage d7bb7c7817
gh-118331: Fix a couple of issues when list allocation fails (#130811)
* Fix use after free in list objects

Set the items pointer in the list object to NULL after the items array
is freed during list deallocation. Otherwise, we can end up with a list
object added to the free list that contains a pointer to an already-freed
items array.

* Mark `_PyList_FromStackRefStealOnSuccess` as escaping

I think technically it's not escaping, because the only object that
can be decrefed if allocation fails is an exact list, which cannot
execute arbitrary code when it is destroyed. However, this seems less
intrusive than trying to special cases objects in the assert in `_Py_Dealloc`
that checks for non-null stackpointers and shouldn't matter for performance.
2025-03-05 10:42:09 -08:00
Sam Gross 2905690a91
gh-130851: Don't crash when deduping unusual code constants (#130853)
The bytecode compiler only generates a few different types of constants,
like str, int, tuple, slices, etc. Users can construct code objects with
various unusual constants, including ones that are not hashable or not
even constant.

The free threaded build previously crashed with a fatal error when
confronted with these constants. Instead, treat distinct objects of
otherwise unhandled types as not equal for the purposes of deduplication.
2025-03-05 15:04:49 +01:00
Serhiy Storchaka f33d21e24f
gh-127750: Improve repr of functools.singledispatchmethod (GH-130220) 2025-03-05 13:10:05 +02:00
Victor Stinner 67a942d427
gh-116742: Fix subprocess test_check_output_timeout() (#130836)
Fix a race condition in test_check_output_timeout() of
test_subprocess. Don't write into stdout anymore, since there is no
reliable way to synchronize the parent and the child processes.

Change the timeout from 3 seconds to 0.1 seconds, and remove
@requires_resource('walltime') decorator.
2025-03-05 10:51:33 +00:00
Peter Bierma 90130807d9
gh-130824: Add tests for `NULL` in `PyLong_*AndOverflow` functions (GH-130828)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-03-05 09:58:39 +01:00
Bert Peters cb67b44ca9
gh-127371 Avoid unbounded growth SpooledTempfile.writelines (GH-127372) 2025-03-05 00:06:07 +02:00
Amit Lavon 691354ccb0
GH-130415: Narrow str to "" based on boolean tests (GH-130476) 2025-03-04 13:20:17 -08:00
Tian Gao b6769e9404
gh-125377: Improve tab indentation for pdb multi-line input (#130471) 2025-03-04 15:45:38 -05:00
Klaus117 c989e74446
GH-130415: Narrow int to 0 based on boolean tests (GH-130772) 2025-03-04 12:44:09 -08:00
Tian Gao e20e47dda6
gh-130660: Add a test for pdb when user quits after interact command (#130852) 2025-03-04 15:10:32 -05:00
Jelle Zijlstra dc6d66f44c
gh-105499: Merge typing.Union and types.UnionType (#105511)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2025-03-04 11:44:19 -08:00
Tomas R. e091520fdb
gh-126085: Add `tp_iter` to TypeAliasType to allow star unpacking (#127981) 2025-03-04 11:34:59 -08:00
Victor Stinner 3dd3675492
gh-130730: Fix multiprocessing test_active_children() (#130837)
Replace a sleep with an event: sleep is not a reliable
synchronization primitive.
2025-03-04 17:05:20 +00:00
Mark Shannon 885c3d126f
GH-90916: Add helper function to dis.Instruction and use it to reduce churn in test_dis (GH-130643) 2025-03-04 16:43:39 +00:00
Tian Gao 63b6ec31c4
gh-82987: Stop on calling frame unconditionally for inline breakpoints (#130493) 2025-03-04 11:35:47 -05:00
Sam Gross efadc5874c
Revert "gh-128041: Add `terminate_workers` and `kill_workers` methods to ProcessPoolExecutor (GH-128043)" (#130838)
The test_concurrent_futures.test_process_pool test is failing in CI.

This reverts commit f97e4098ff.
2025-03-04 11:19:06 -05:00
Victor Stinner f67ff9e820
gh-130727: Retry test_wmi on TimeoutError (#130832)
Use sleeping_retry() in test_wmi to retry multiple times on
TimeoutError. Wait up to LONG_TIMEOUT seconds (5 minutes by default).
2025-03-04 16:07:01 +01:00
Jelle Zijlstra 1d251b8339
gh-128184: Fix display of signatures with ForwardRefs (#130815)
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-03-04 06:58:37 -08:00
Petr Viktorin d91cc9db15
gh-129666: Add C11/C++11 to docs and -pedantic-errors to GCC/clang test_c[pp]ext tests (GH-130692)
Disable pedantic check for c++03 (unlimited API)

Also add a check for c++03 *limited* API, which passes in pedantic mode
after removing a comma in the `PySendResult` declaration, and allowing
`long long`.
2025-03-04 14:10:09 +01:00
Victor Stinner 6c48ed7d62
gh-130736: Fix asyncio test_shutdown_default_executor_timeout() (#130800)
Replace time.sleep() with threading.Event.
2025-03-04 11:16:07 +00:00
Bénédikt Tran 3929af5e3a
gh-89083: add support for UUID version 7 (RFC 9562) (#121119)
Add support for generating UUIDv7 objects according to RFC 9562, §5.7 [1].

The functionality is provided by the `uuid.uuid7()` function. The implementation
is based on a 42-bit counter as described by Method 1, §6.2 [2] and guarantees
monotonicity within the same millisecond.

[1]: https://www.rfc-editor.org/rfc/rfc9562.html#section-5.7
[2]: https://www.rfc-editor.org/rfc/rfc9562.html#section-6.2

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Éric <merwok@netwok.org>
2025-03-04 10:47:19 +01:00
Bénédikt Tran 15d926b285
gh-130149: fix HMAC tests for some FIPS-only build bots (#130788)
Skips some HMAC tests for some FIPS-only build bots that do not have the underlying hash functions.
2025-03-04 10:15:33 +01:00
Andrii Hrimov d780f0af2b
gh-130486: Fix test_venv fails from within venv (GH-130487) 2025-03-04 07:48:07 +00:00
Tomas R. bbf197913c
gh-124445: Allow specializing generic ParamSpec aliases (#124512)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2025-03-03 14:58:33 -08:00
Victor Stinner 8a64a62002
gh-130737: Fix multiprocessing test_notify() (#130797)
Replace hardcoded delay (100 ms) with a loop awaiting until a
condition is true: replace assertReturnsIfImplemented() with
assertReachesEventually().

Use sleeping_retry() in assertReachesEventually() to tolerate slow
buildbots and raise an exception on timeout (30 seconds).
2025-03-03 18:45:26 +00:00
Barney Gale d0eb01c9de
GH-128520: Merge `pathlib._abc` into `pathlib.types` (#130747)
There used to be a meaningful distinction between these modules: `pathlib`
imported `pathlib._abc` but not `pathlib.types`. This is no longer the
case (neither module is imported), so we move the ABCs as follows:

- `pathlib._abc.JoinablePath` --> `pathlib.types._JoinablePath`
- `pathlib._abc.ReadablePath` --> `pathlib.types._ReadablePath`
- `pathlib._abc.WritablePath` --> `pathlib.types._WritablePath`
2025-03-03 17:56:57 +00:00
Tomas R. 321bf59512
gh-130453: pygettext: Allow overriding default keywords when using `--keyword` (GH-130709) 2025-03-03 18:57:01 +02:00
Chris Withers 04091c0833
`unittest.mock` test and coverage fixup (#130787)
* Mark functions that will never be called with # pragma: no cover

* Fix testpatch.PatchTest.test_exit_idempotent

.stop() and __exit__ have subtly different code paths, so to really test __exit__ idempotency, we need to call it specifically twice.
2025-03-03 11:44:59 +00:00
Bénédikt Tran 8f11af45de
gh-130149: refactor tests for HMAC (#130150)
Since we plan to introduce a built-in implementation for HMAC based on HACL*,
it becomes important for the HMAC tests to be flexible enough to avoid code
duplication.

In addition to the new layout based on mixin classes, we extend test coverage by
also testing the `__repr__` of HMAC objects and the HMAC one-shot functions.

We also fix the import to `_sha256` which, since gh-101924, resulted in some tests being
skipped as the module is no more available (its content was moved to the `_sha2` module).
2025-03-03 11:22:05 +01:00
Charles Machalow f97e4098ff
gh-128041: Add `terminate_workers` and `kill_workers` methods to ProcessPoolExecutor (GH-128043)
This adds two new methods to `multiprocessing`'s `ProcessPoolExecutor`:
- **`terminate_workers()`**: forcefully terminates worker processes using `Process.terminate()`
- **`kill_workers()`**: forcefully kills worker processes using `Process.kill()`

These methods provide users with a direct way to stop worker processes without `shutdown()` or relying on implementation details, addressing situations where immediate termination is needed.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Commit-message-mostly-authored-by: Claude Sonnet 3.7 (because why not -greg)
2025-03-02 18:01:45 -08:00
Brandt Bucher 7afa476874
GH-130415: Use boolean guards to narrow types to values in the JIT (GH-130659) 2025-03-02 13:21:34 -08:00
Kanishk Pachauri a42168d316
gh-130637: Add validation for numeric response data in `stat()` method (#130646)
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
2025-03-02 08:05:40 -05:00
Bénédikt Tran 990ad272f6
gh-89083: add support for UUID version 6 (RFC 9562) (#120650)
Add support for generating UUIDv6 objects according to RFC 9562, §5.6 [1].

The functionality is provided by the `uuid.uuid6()` function which takes as inputs an optional 48-bit
hardware address and an optional 14-bit clock sequence. The UUIDv6 temporal fields are ordered
differently than those of UUIDv1, thereby providing improved database locality.

[1]: https://www.rfc-editor.org/rfc/rfc9562.html#section-5.6

---------

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-03-02 12:41:56 +01:00
Barney Gale c9932a9ec8
GH-127381: pathlib ABCs: remove `WritablePath.mkdir()` arguments (#130611)
Remove the *mode*, *parents* and *exist_ok* arguments from
`WritablePath.mkdir()`. These arguments imply support for POSIX permissions
and checking for preexistence of the path or its parents, but subclasses of
`WritablePath` may not have these capabilities.

The public `Path.mkdir()` method retains these arguments.
2025-03-01 21:25:38 +00:00
Barney Gale a55dffd66d
GH-127381: pathlib ABCs: remove `ReadablePath.exists()` and `is_*()` (#130520)
Remove `ReadablePath` methods duplicated by `ReadablePath.info`. To be
specific, we remove `exists()`, `is_dir()`, `is_file()` and `is_symlink()`.

The public `Path` class retains these methods.
2025-03-01 21:24:19 +00:00
Duprat a98a6bd112
gh-129401: Test repr rlock failing randomly (#129959)
Fix and simplify a test of `test_repr_rlock` about multiprocessing.RLock primitive.
2025-03-01 15:28:14 -05:00
Barney Gale 5326c27fc6
Revert "GH-116380: Speed up `glob.[i]glob()` by making fewer system calls. (#116392)" (#130743)
This broke tests on the 'aarch64 Fedora Stable Clang Installed 3.x' and
'AMD64 Fedora Stable Clang Installed 3.x' build bots.

This reverts commit da4899b94a.
2025-03-01 20:04:01 +00:00
Sam Gross 5221d9ce0e
Revert "gh-128364: Fix flaky `test_timeout` test (gh-130724)" (gh-130732)
Change broke Android and iOS buildbots that do not have multiprocessing.

This reverts commit cfa0b1dc37.
2025-03-01 17:22:13 +00:00
Sam Gross cfa0b1dc37
gh-128364: Fix flaky `test_timeout` test (gh-130724) 2025-03-01 16:20:43 +00:00
Bénédikt Tran ddc27f9c38
gh-128974: Fix `UnicodeError.__str__` when custom attributes have side-effects (#128975)
Fix some crashes when (custom) attributes of `UnicodeError` objects implement `object.__str__` with side-effects.
2025-03-01 12:01:20 +01:00
Sam Gross 75f38af781
Revert "gh-128942: make `array` module thread safe (#128943)" (#130707)
The change regressed performance on scimark benchmarks from the
pyperformance benchmark suite.

This reverts commit 8ba0d7bbc2.
2025-02-28 16:57:48 -05:00
Barney Gale da4899b94a
GH-116380: Speed up `glob.[i]glob()` by making fewer system calls. (#116392)
## Filtered recursive walk

Expanding a recursive `**` segment entails walking the entire directory
tree, and so any subsequent pattern segments (except special segments) can
be evaluated by filtering the expanded paths through a regex. For example,
`glob.glob("foo/**/*.py", recursive=True)` recursively walks `foo/` with
`os.scandir()`, and then filters paths through a regex based on "`**/*.py`,
with no further filesystem access needed.

This fixes an issue where `glob()` could return duplicate results.

## Tracking path existence

We store a flag alongside each path indicating whether the path is
guaranteed to exist. As we process the pattern:

- Certain special pattern segments (`""`, `"."` and `".."`) leave the flag
  unchanged
- Literal pattern segments (e.g. `foo/bar`) set the flag to false
- Wildcard pattern segments (e.g. `*/*.py`) set the flag to true (because
  children are found via `os.scandir()`)
- Recursive pattern segments (e.g. `**`) leave the flag unchanged for the
  root path, and set it to true for descendants discovered via
  `os.scandir()`.

If the flag is false at the end, we call `lstat()` on each path to filter
out missing paths.

## Minor speed-ups

- Exclude paths that don't match a non-terminal non-recursive wildcard
  pattern _prior_ to calling `is_dir()`.
- Use a stack rather than recursion to implement recursive wildcards.
  - This fixes a recursion error when globbing deep trees.
- Pre-compile regular expressions and pre-join literal pattern segments.
- Convert to/from `bytes` (a minor use-case) in `iglob()` rather than
  supporting `bytes` throughout. This particularly simplifies the code
  needed to handle relative bytes paths with `dir_fd`.
- Avoid calling `os.path.join()`; instead we keep paths in a normalized
  form and append trailing slashes when needed.
- Avoid calling `os.path.normcase()`; instead we use case-insensitive regex
  matching.

## Implementation notes

Much of this functionality is already present in pathlib's implementation
of globbing. The specific additions we make are:

1. Support for `dir_fd`
2. Support for `include_hidden`
3. Support for generating paths relative to `root_dir`

This unifies the implementations of globbing in the `glob` and `pathlib`
modules.

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-28 20:33:51 +00:00
Barney Gale b545450961
GH-130608: Remove `dirs_exist_ok` argument from `pathlib.Path.copy()` (#130610)
This feature isn't sufficiently motivated.
2025-02-28 19:29:20 +00:00
Tian Gao fdcbc29f26
gh-130660: Restore sys.ps1 and sys.ps2 after code.interact (#130661) 2025-02-28 13:15:55 -05:00
Mark Shannon 54965f3fb2
GH-130296: Avoid stack transients in four instructions. (GH-130310)
* Combine _GUARD_GLOBALS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_MODULE_FROM_KEYS into _LOAD_GLOBAL_MODULE

* Combine _GUARD_BUILTINS_VERSION_PUSH_KEYS and _LOAD_GLOBAL_BUILTINS_FROM_KEYS into _LOAD_GLOBAL_BUILTINS

* Combine _CHECK_ATTR_MODULE_PUSH_KEYS and _LOAD_ATTR_MODULE_FROM_KEYS into _LOAD_ATTR_MODULE

* Remove stack transient in LOAD_ATTR_WITH_HINT
2025-02-28 18:00:38 +00:00
Petr Viktorin ab11c09705
gh-129666: Revert "gh-129666: Add C11/C++11 to docs and `-pedantic-errors` to GCC/clang test_c[pp]ext tests (GH-130686)" (GH-130688)
This reverts commit 003e6d2b97.
2025-02-28 16:05:36 +00:00
Petr Viktorin 003e6d2b97
gh-129666: Add C11/C++11 to docs and `-pedantic-errors` to GCC/clang test_c[pp]ext tests (GH-130686) 2025-02-28 16:03:02 +01:00
Ilya Bazhenov 9f0879baf1
gh-130607: Extend and cleanup IPv6 tests (GH-121518)
Extend IPv6 tests and made little syntax refactoring
2025-02-28 11:31:30 +01:00
Tomas R. 24c52cb14c
gh-130655: Increase test coverage of gettext._expand_lang() (GH-130656) 2025-02-28 10:40:36 +02:00
Cody Maloney 7f39137662
gh-129726: Break `gzip.GzipFile` reference loop (#130055)
A reference loop was resulting in the `fileobj` held by the `GzipFile`
being closed before the `GzipFile`.

The issue started with gh-89550 in 3.12, but was hidden in most cases
until 3.13 when gh-62948 made it more visible.
2025-02-28 09:09:24 +01:00
Pablo Galindo Salgado e06bebb87e
gh-130618: Fix parser error when using lambdas inside f-strings (#130638) 2025-02-27 15:51:17 +00:00
Tomasz Pytel e85f81f430
gh-129107: fix thread safety of `bytearray` where two critical sections are needed (#130227) 2025-02-27 20:29:58 +05:30
Tomasz Pytel 8ba0d7bbc2
gh-128942: make `array` module thread safe (#128943)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-27 14:00:14 +00:00
Fredrik Ahlberg 45a24f54af
gh-129288: Add optional l2_cid and l2_bdaddr_type in BTPROTO_L2CAP socket address tuple (#129293)
Add two optional, traling elements in the AF_BLUETOOTH socket address tuple:

- l2_cid, to allow e.g raw LE ATT connections
- l2_bdaddr_type. To be able to connect L2CAP sockets to Bluetooth LE devices,
  the l2_bdaddr_type must be set to BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM.
2025-02-27 12:51:47 +00:00
Victor Stinner a083633fa0
gh-109959: Remove test_glob.test_selflink() (#130551)
The test is not reliable, it fails randomly on Linux:
https://github.com/python/cpython/issues/109959#issuecomment-2577550700
2025-02-27 11:07:08 +01:00
Mark Shannon 2a18e80695
GH-128534: Instrument branches for `async for` loops. (GH-130569) 2025-02-27 09:36:41 +00:00
Sam Gross 959f43315e
gh-130605: Temporarily disable test_concurrent_futures in TSAN CI job (gh-130606)
There are a number of data races in the default build without
suppressions that are exposed by this test. Disable the test for now
under TSAN until we have suppressions or fix the data races.
2025-02-26 21:36:53 +00:00
Sam Gross 45bc120d45
gh-130519: Fix crash in QSBR when destructor reenters QSBR (gh-130553)
The `free_work_item()` function in QSBR may call arbitrary code via
Python object destructors, which may reenter the QSBR code. Reorder
the processing of work items to be robust to reentrancy.

Also fix the TODO for the out of memory situation.
2025-02-26 14:55:15 -05:00
Petr Viktorin 9e474a98af
gh-128982: Revert "#128982: Substitute regular expression in http.cookiejar.join_header_words for an efficient alternative (GH-128983)" and add tests (GH-130584)
* Revert "gh-128982: Substitute regular expression in `http.cookiejar.join_header_words` for an efficient alternative (GH-128983)"

This reverts commit 56e1900681.

* Add tests
2025-02-26 15:42:39 +01:00
Paul Moore 64ccbbbf36
gh-130379: Fix incorrect zipapp logic to avoid including the target in itself (gh-130509) 2025-02-26 11:25:30 +00:00
Mark Shannon 129db32d6f
GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550) 2025-02-26 09:01:58 +00:00
Serhiy Storchaka 0ef4ffeefd
gh-130163: Fix crashes related to PySys_GetObject() (GH-130503)
The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
2025-02-25 23:04:27 +02:00
Tian Gao c5f925c8c9
gh-122029: Move monitoring after method expand for CALL_KW (GH-130488) 2025-02-25 15:43:49 +00:00
Sam Gross 3774d9f7b5
gh-129824: Temporarily skip InterpreterPoolMixin tests under TSAN (gh-129826)
There are multiple data races reported when running the
InterpreterPoolMixin tests, but it's still useful to run the other
test_concurrent_futures tests under TSAN.

Add test_concurrent_futures to the TSAN test suite.
2025-02-25 10:33:04 -05:00
Sergey B Kirpichev f39a07be47
gh-87790: support thousands separators for formatting fractional part of floats (#125304)
```pycon
>>> f"{123_456.123_456:_._f}"  # Whole and fractional
'123_456.123_456'
>>> f"{123_456.123_456:_f}"    # Integer component only
'123_456.123456'
>>> f"{123_456.123_456:._f}"   # Fractional component only
'123456.123_456'
>>> f"{123_456.123_456:.4_f}"  # with precision
'123456.1_235'
```
2025-02-25 16:27:07 +01:00
Tomas R. 44213bc57c
gh-130453: pygettext: Extend support for specifying custom keywords (GH-130463) 2025-02-25 12:10:54 +02:00
Mark Shannon 014223649c
GH-130396: Use computed stack limits on linux (GH-130398)
* Implement C recursion protection with limit pointers for Linux, MacOS and Windows

* Remove calls to PyOS_CheckStack

* Add stack protection to parser

* Make tests more robust to low stacks

* Improve error messages for stack overflow
2025-02-25 09:24:48 +00:00
Tian Gao 56e337d32b
Fix a typo in code module test (#130530) 2025-02-25 00:33:52 -05:00
Adam D. Thomas ccb4ad9219
gh-124703: Change back to raising bdb.BdbQuit when exiting pdb in 'inline' mode in a REPL session (#130395) 2025-02-24 21:27:26 -05:00
Barney Gale 78e09a488d
GH-125413: Fix stale metadata from `pathlib.Path.copy()` and `move()` (#130424)
In `pathlib.Path.copy()` and `move()`, return a fresh `Path` object with an
unpopulated `info` attribute, rather than a `Path` object with information
recorded *prior* to the path's creation.
2025-02-24 19:10:50 +00:00
Barney Gale 48c84a400a
GH-125413: pathlib ABCs: use caching `path.info.exists()` when globbing (#130422)
Call `ReadablePath.info.exists()` rather than `ReadablePath.exists()` when
globbing so that we use (or populate) the `info` cache.
2025-02-24 19:07:54 +00:00
Kumar Aditya d73d69e232
gh-129874: improve tests to use correct implementations in asyncio (#130516) 2025-02-24 21:33:52 +05:30
Russell Keith-Magee 8a76eb8469
gh-130384: Skip a test_getallocatedblocks test pre-condition on iOS. (GH-130385) 2025-02-24 15:34:38 +00:00
Bartosz Sławecki 7ed3dc6392
gh-128231: Use `runcode()` return value for failing early (GH-129488) 2025-02-24 15:50:13 +01:00
Petr Viktorin fc8d2cba54
gh-129405: Fix doc for Py_mod_multiple_interpreters default, and add test (GH-129406) 2025-02-24 14:59:19 +01:00
Petr Viktorin ef29104f7d
GH-91079: Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now (GH130413)
Revert "GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)" for now

Unfortunatlely, the change broke some buildbots.

This reverts commit 2498c22fa0.
2025-02-24 11:16:08 +01:00
donBarbos 81a9b53fee
gh-107773: Make `datetime` subclass `repr` consistent both implementations (#130308)
---------

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2025-02-23 16:29:31 -05:00
mingyu 9f81f828c7
gh-129948: Add `set()` to `multiprocessing.managers.SyncManager` (#129949)
The SyncManager provided support for various data structures such as dict, list, and queue, but oddly, not set.
This introduces support for set by defining SetProxy and registering it with SyncManager.

---
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-02-23 20:07:33 +00:00
Y5 a65366ed87
gh-124096: Enable REPL virtual terminal support on Windows (#124119)
To support virtual terminal mode in Windows PYREPL, we need a scanner
to read over the supported escaped VT sequences.

Windows REPL input was using virtual key mode, which does not support
terminal escape sequences. This patch calls `SetConsoleMode` properly
when initializing and send sequences to enable bracketed-paste modes
to support verbatim copy-and-paste.

Signed-off-by: y5c4l3 <y5c4l3@proton.me>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Dustin L. Howett <dustin@howett.net>
Co-authored-by: wheeheee <104880306+wheeheee@users.noreply.github.com>
2025-02-23 20:30:33 +01:00
Jacob Austin Lincoln 25a7ddf2ef
gh-65697: Prevent configparser from writing keys it cannot properly read (#129270)
---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-02-23 11:06:33 -05:00
Daraan d8ce092fe4
Add test checking value of a TypedDict's __total__ attribute when there is an assignment in the class body. (#130460)
In relation to #109544 which changed this behavior.

Signed-off-by: Daniel Sperber <github.blurry@9ox.net>
2025-02-22 09:34:22 -08:00
Yan Yanchii 38642bff13
gh-126835: Move constant unaryop & binop folding to CFG (#129550) 2025-02-21 17:54:22 +00:00
Raymond Hettinger 286c517db0
gh-130285: Fix handling of zero or empty counts in random.sample() (gh-130291) 2025-02-21 11:33:10 -06:00
Pieter Eendebak 0c4248f88e
gh-126332: Add tests for _pyrepl.utils (#129325) 2025-02-21 16:10:13 +00:00
Hugo van Kemenade 1cf9b6d9b8
gh-129965: Add missing MIME types (#129969)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-02-21 15:44:53 +00:00
Victor Stinner f1b81c408f
gh-129363: Change regrtest sequential mode output (#129476)
First, write the test name without color. Then, write the test name
and the result with color. Each test is displayed twice.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-02-21 14:55:32 +01:00
Hizuru c359fcd2f5
gh-129569: The function unicodedata.normalize() always returns built-in str (#129570)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-02-21 14:51:13 +01:00
Sam Gross 35925e9529
gh-129269: Exclude everything in sys.path in `test_coverage_ignore` (gh-130133)
The `test_trace.test_coverage_ignore` test would fail if you had
`setuptools` installed, such as in `~/.local/lib/python3.xxx/site-packages/`.
Ignore everything in `sys.path` when running the test.
2025-02-20 10:13:44 -05:00
Irit Katriel 048ee2d5ec
gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state (#130342) 2025-02-20 11:29:18 +00:00
Serhiy Storchaka 10b32054ad
gh-127750: Restore inspect and pydoc support of singledispatchmethod (GH-130309)
The code is still flawed, because it does not recognize class and static
methods, and the first argument is not removed from the signature of
bound methods, but at least it does not worse than in 3.13 and older.
2025-02-20 11:08:49 +02:00
Russell Keith-Magee 1b070060c0
gh-130293: Ensure test__colorize will pass on dumb terminals. (#130333)
Ensure colorize tests will run on dumb terminals (or environment with TERM=dumb set)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-02-20 06:49:18 +00:00
Tian Gao ee337bea01
gh-57537: Support breakpoints for zipimport modules on pdb (#130290) 2025-02-19 21:01:04 -05:00
Irit Katriel c718c6be0f
gh-130250: fix cleanup in test (impacts refleaks runs) (#130329) 2025-02-20 01:37:30 +00:00
Irit Katriel 6c982aeb54
gh-130250: fix regression in traceback.print_last (#130318) 2025-02-19 21:44:35 +00:00
Tian Gao ccf17323c2
gh-128396: Fix a crash when inline comprehension has the same local variable as the outside scope (#130235) 2025-02-19 12:11:17 -05:00
Mark Shannon 2498c22fa0
GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)
* Implement C recursion protection with limit pointers

* Remove calls to PyOS_CheckStack

* Add stack protection to parser

* Make tests more robust to low stacks

* Improve error messages for stack overflow
2025-02-19 11:44:57 +00:00
Tomasz Pytel 1b6bef8086
gh-129107: make `bytearray` iterator thread safe (#130096)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-19 15:42:45 +05:30
T. Wouters 388e1ca9f0
gh-115999: Make list and tuple iteration more thread-safe. (#128637)
Make tuple iteration more thread-safe, and actually test concurrent iteration of tuple, range and list. (This is prep work for enabling specialization of FOR_ITER in free-threaded builds.) The basic premise is:

Iterating over a shared iterable (list, tuple or range) should be safe, not involve data races, and behave like iteration normally does.

Using a shared iterator should not crash or involve data races, and should only produce items regular iteration would produce. It is not guaranteed to produce all items, or produce each item only once. (This is not the case for range iteration even after this PR.)

Providing stronger guarantees is possible for some of these iterators, but it's not always straight-forward and can significantly hamper the common case. Since iterators in general aren't shared between threads, and it's simply impossible to concurrently use many iterators (like generators), better to make sharing iterators without explicit synchronization clearly wrong.

Specific issues fixed in order to make the tests pass:

 - List iteration could occasionally fail an assertion when a shared list was shrunk and an item past the new end was retrieved concurrently. There's still some unsafety when deleting/inserting multiple items through for example slice assignment, which uses memmove/memcpy.

 - Tuple iteration could occasionally crash when the iterator's reference to the tuple was cleared on exhaustion. Like with list iteration, in free-threaded builds we can't safely and efficiently clear the iterator's reference to the iterable (doing it safely would mean extra, slow refcount operations), so just keep the iterable reference around.
2025-02-18 16:52:46 -08:00
Tian Gao 8207454bc0
gh-124703: Add extra checks for pdb quit test (#130286) 2025-02-18 16:55:39 -05:00
Sergey Miryanov bcc9a5dddb
gh-129515: Clarify syntax error messages for conditional expressions (#129880)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-18 21:43:19 +00:00
Tian Gao 076300d795
gh-126944: Show explicit errors when required arguments of pdb commands are missing (#130240) 2025-02-18 10:58:15 -05:00
donBarbos 427dd10250
gh-127260: Improve error consistency in both `fromisoformat` implementations (#130134)
In the Python implementation, "Z" was allowed where only "+" or "-" should be allowed in time zone specifiers. In the C implementation, ":" was allowed as a separator between the whole and fractional portion of times (seconds). These have both been forbidden and the error messages harmonized.
2025-02-18 15:49:28 +00:00
Jacob Walls dab456dcef
gh-130164: Fix inspect.Signature.bind() handling of positional-only args without defaults (GH-130192)
Follow-up to 9c15202.
2025-02-18 17:19:04 +02:00
Stan Ulbrych 01ba7df499
gh-44827: Improve error if BOM on first line of .po file (GH-130187) 2025-02-18 15:59:34 +02:00
Kumar Aditya 2e3e65380b
improve `test_tasks` to use correct idiom for starting task in asyncio (#130257)
The test should use the correct idiom for starting the task, `loop._run_once` is private API which should not be used directly, instead use `asyncio.sleep(0)` for 1 event loop cycle.
2025-02-18 12:08:25 +00:00
Serhiy Storchaka b93b7e566e
gh-130230: Fix crash in pow() with only Decimal third argument (GH-130237) 2025-02-18 09:46:48 +02:00
Barney Gale 6f07016bf0
GH-127381: pathlib ABCs: remove `ReadablePath.rglob()` (#130207)
Remove `ReadablePath.rglob()` from the private pathlib ABCs. This method is
a trivial wrapper around `glob()` and easily replaced.
2025-02-17 19:15:59 +00:00
Barney Gale 7fcace99bb
GH-125413: Add private metadata methods to `pathlib.Path.info` (#129897)
Add the following private methods to `pathlib.Path.info`:

- `_posix_permissions()`: the POSIX file permissions (`S_IMODE(st_mode)`)
- `_file_id()`: the file ID (`(st_dev, st_ino)`)
- `_access_time_ns()`: the access time in nanoseconds (`st_atime_ns`)
- `_mod_time_ns()`: the modify time in nanoseconds (`st_mtime_ns`)
- `_bsd_flags()`: the BSD file flags (`st_flags`)
- `_xattrs()`: the file extended attributes as a list of key, value pairs,
  or an empty list if `listxattr()` or `getxattr()` fail in an ignorable 
  way.

These methods replace `LocalCopyReader.read_metadata()`, and so we can
delete the `CopyReader` and `LocalCopyReader` classes. Rather than reading
metadata via `source._copy_reader.read_metadata()`, we instead call
`source.info._posix_permissions()`, `_access_time_ns()`, etc.

Preserving metadata is only supported for local-to-local copies at the
moment. To support copying metadata between arbitrary `ReadablePath` and
`WritablePath` objects, we'd need to make the new methods public and
documented.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-02-17 19:15:25 +00:00
Andrey Efremov ef8eeca9d8
gh-129678: ConfigParser: do not write an empty unnamed section (GH-129679)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-02-17 14:24:57 +01:00
Tomas R. aa845af9bb
gh-130057: Pygettext: Support translator comments (GH-130061) 2025-02-17 12:41:28 +02:00
Serhiy Storchaka 395335d0ff
gh-127750: Fix and optimize functools.singledispatchmethod() (GH-130008)
Remove broken singledispatchmethod caching introduced in gh-85160.
Achieve the same performance using different optimization.

* Add more tests.

* Fix issues with __module__ and __doc__ descriptors.
2025-02-17 11:11:20 +02:00
Tomas R. fb2d325725
gh-130193: Increase test coverage of gettext.c2py (GH-130208) 2025-02-17 10:57:34 +02:00
Serhiy Storchaka cfe41037eb
gh-86069: Add more PyNumber_InPlacePower() tests (GH-130111)
Test it with the third argument.
2025-02-17 00:07:10 +00:00
Tomas R. 73d03005b0
gh-130185: Fix unintentionally skipped tests in `test_functools` (#130186) 2025-02-16 16:34:54 +03:00
Irit Katriel c9b1bf302c
gh-130139: always check ast node type in ast.parse() with ast input (#130140) 2025-02-16 13:32:39 +00:00
Tomas R. 2e8044a4f7
gh-130177: Fix unintentionally skipped tests in test_gettext (GH-130178) 2025-02-16 14:14:37 +02:00
Tomas R. 361083b84b
gh-127488: Add tests for Tools/i18n/msgfmt.py (GH-127540) 2025-02-16 14:05:01 +02:00
AN Long 798f8d3ea9
Replace non-breaking spaces with normal spaces (#130116)
Using normal spaces in place of non-breaking spaces.
2025-02-16 09:33:14 +08:00
Barney Gale a7d41a8947
GH-128520: Subclass `abc.ABC` in `pathlib._abc` (#128745)
Convert `JoinablePath`, `ReadablePath` and `WritablePath` to real ABCs
derived from `abc.ABC`.

Make `JoinablePath.parser` abstract, rather than defaulting to `posixpath`.

Register `PurePath` and `Path` as virtual subclasses of the ABCs rather
than deriving. This avoids a hit to path object instantiation performance.

No change of behaviour in the public (non-abstract) classes.
2025-02-16 00:37:26 +00:00
Ken Jin 359c7dde3b
gh-129989: Properly disable tailcall interp in configure (GH-129991)
Co-authored-by: Zanie Blue <contact@zanie.dev>
2025-02-16 03:01:24 +08:00
Kumar Aditya a545749b0e
gh-130145: fix `loop.run_forever` when loop is already running (#130146) 2025-02-15 15:01:53 +05:30
Tomasz Pytel a05433f24a
gh-129107: make `bytearray` thread safe (#129108)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-15 07:19:42 +00:00
Sam Gross 39cd9728a6
gh-130095: Mark `_py_abc` tests as not thread-safe (gh-130131)
The `_py_abc` implementation is not currently thread-safe (even with the GIL).
Don't run these tests with `--parallel-threads=N` for now.
2025-02-14 16:21:45 -05:00
Stan Ulbrych 3402e133ef
gh-82045: Correct and deduplicate "isprintable" docs; add test. (GH-130118)
We had the definition of what makes a character "printable" documented in three places, giving two different definitions.
The definition in the comment on `_PyUnicode_IsPrintable` was inverted; correct that.

With that correction, the two definitions turn out to be equivalent -- but to confirm that, you have to go look up, or happen to know, that those are the only five "Other" categories and only three "Separator" categories in the Unicode character database.  That makes it hard for the reader to tell whether they really are the same, or if there's some subtle difference in the intended semantics.

Fix that by cutting the C API docs' and the C comment's copies of the subtle details, in favor of referring to the Python-level docs. That ensures it's explicit that these are all meant to agree, and also lets us concentrate improvements to the wording in one place.

Speaking of which, borrow some ideas from the C comment, along with other tweaks, to hopefully add a bit more clarity to that one newly-centralized copy in the docs.

Also add a thorough test that the implementation agrees with this definition.

Author:    Greg Price <gnprice@gmail.com>

Co-authored-by: Greg Price <gnprice@gmail.com>
2025-02-14 18:16:47 +01:00
Yan Yanchii 334589f619
gh-126835: Set location for noped out instructions after constant folding in CFG. (#130109) 2025-02-14 14:15:08 +00:00
Tomas R. 0f20281fa2
gh-107510: gettext: Remove unnecessary tests (GH-127965)
There are now separate pygettext tests.
2025-02-14 12:16:10 +00:00
Tomas R. 9d1e668e6f
gh-129911: pygettext: Fix the keyword entry in help output (GH-129914) 2025-02-14 11:34:09 +02:00
Pablo Galindo Salgado 3bd3e09588
gh-125331: Allow the parser to activate future imports on the fly (#125482) 2025-02-14 04:54:56 +00:00
Filipe Laíns 🇵🇸 1eb3ade6e5
GH-107956: install build-details.json (PEP 739) (#130069) 2025-02-13 13:58:00 +00:00
Yan Yanchii 140e69c4a8
gh-126835: Move const folding of lists & sets from ast_opt.c to flowgraph.c (#130032) 2025-02-13 12:11:07 +00:00
Ammar Askar f9a7d41bac
gh-96092: Fix traceback.walk_stack(None) skipping too many frames (#129330)
As it says in its documentation, walk_stack was meant to just
follow `f.f_back` like other functions in the traceback module.
Instead it was previously doing `f.f_back.f_back` and then this
changed to `f_back.f_back.f_back.f_back' in Python 3.11 breaking
its behavior for external users.

This happened because the walk_stack function never really had
any good direct tests and its only consumer in the traceback module was
`extract_stack` which passed the result into `StackSummary.extract`.
As a generator, it was previously capturing the state of the stack
when it was first iterated over, rather than the stack when `walk_stack`
was called. Meaning when called inside the two method deep
`extract` and `extract_stack` calls, two `f_back`s were needed.
When 3.11 modified the sequence of calls in `extract`, two more
`f_back`s were needed to make the tests happy.

This changes the generator to capture the stack when `walk_stack` is
called, rather than when it is first iterated over. Since this is
technically a breaking change in behavior, there is a versionchanged
to the documentation. In practice, this is unlikely to break anyone,
you would have been needing to store the result of `walk_stack` and
expecting it to change.
2025-02-13 01:43:09 +00:00
Pablo Galindo Salgado 6fb5138776
gh-88535: Improve syntax error for wrongly closed strings (#26633) 2025-02-13 01:30:20 +00:00
Pablo Galindo Salgado 56eda25633
gh-116042: Fix location for SyntaxErrors of invalid escapes in the tokenizer (#116049) 2025-02-13 01:07:37 +00:00
Tomas R. 2dd018848c
gh-129693: Suppress `SyntaxWarning` in test_fstring (#129830)
Suppress SyntaxWarning in test_fstring
2025-02-13 00:38:28 +00:00
Mark Shannon 72f56654d0
GH-128682: Account for escapes in `DECREF_INPUTS` (GH-129953)
* Handle escapes in DECREF_INPUTS

* Mark a few more functions as escaping

* Replace DECREF_INPUTS with PyStackRef_CLOSE where possible
2025-02-12 17:44:59 +00:00
donBarbos 3e222e3a15
gh-109798: Normalize `_datetime` and `datetime` error messages (#127345)
Updates error messages in datetime and makes them consistent between Python and C.

---------

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2025-02-12 09:54:22 -05:00
Andrew Svetlov 469d2e416c
gh-129889: Support context manager protocol by contextvars.Token (#129888) 2025-02-12 12:32:58 +01:00
Sam Gross a7427f2db9
gh-129967: Fix race condition in `repr(set)` (gh-129978)
The call to `PySequence_List()` could temporarily unlock and relock the
set, allowing the items to be cleared and return the incorrect
notation `{}` for a empty set (it should be `set()`).

Co-authored-by: T. Wouters <thomas@python.org>
2025-02-11 17:29:27 -05:00
Sam Gross 1f233f56d6
gh-128657: Skip test_get_builtin_constructor when running with --parallel-threads (GH-130018)
The test modifies sys.modules and is not thread-safe.
2025-02-11 16:59:36 -05:00
Sam Gross 1a8082a4bf
gh-117657: Add test_thread_local_bytecode to TSAN tests (gh-129753)
Skip `test_no_copies_if_tlbc_disabled` when run under TSAN for now
due to a data race on the adaptive counter (see gh-129752).
2025-02-11 16:54:32 -05:00
Sam Gross f151d27159
gh-117657: Enable test_opcache under TSAN (GH-129831)
Fix a few thread-safety bugs to enable test_opcache when run with TSAN:

 * Use relaxed atomics when clearing `ht->_spec_cache.getitem`
   (gh-115999)
 * Add temporary suppression for type slot modifications (gh-127266)
 * Use atomic load when reading `*dictptr`
2025-02-11 16:53:08 -05:00
Sam Gross 3b548adc76
gh-129980: Include test name in TSAN filename in multiprocess test runner (GH-129981) 2025-02-11 12:09:43 -05:00
Tomas R. 374abded07
gh-104400: pygettext: use an AST parser instead of a tokenizer (GH-104402)
This greatly simplifies the code and fixes many corner cases.
2025-02-11 13:51:42 +02:00
Wulian233 12bd15f7b3
gh-129939: Add darkmode support for difflib's comparison pages (#129940) 2025-02-11 10:58:57 +02:00
Erlend E. Aasland 3a2e7aacf6
gh-129928: Raise more accurate exception for incorrect sqlite3 UDF creation (#129941)
Consistently raise ProgrammingError if the user tries to create an UDF
with an invalid number of parameters.
2025-02-11 08:26:01 +01:00
Kumar Aditya 94cd2e0dde
gh-129289: fix crash when task finalizer is not called in asyncio (#129840) 2025-02-10 17:03:59 +05:30
Peter Marko 978211c8a8
gh-126554: correct detection of `gcc` for `TestNullDlsym.test_null_dlsym` (GH-129872)
In case gcc is not available, the test will fail with FileNotFoundError.
So catch the exception to skip the test correctly.

Signed-off-by: Peter Marko <peter.marko@siemens.com>
2025-02-10 10:51:56 +01:00
Erlend E. Aasland 7e6ee50b6b
gh-129603: Don't segfault if sqlite3.Row description is None (#129604) 2025-02-10 00:27:28 +01:00
Erlend E. Aasland cda83cade0
gh-129870: Skip test_dump_virtual_tables if SQLite lacks FTS4 support (#129913) 2025-02-09 21:43:23 +01:00
Yan Yanchii 91d9544112
gh-126835: Make CFG optimizer skip over NOP's when looking for const sequence construction (#129703)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-02-09 18:00:41 +00:00
Kumar Aditya f7c7decc4c
gh-129874: improve test_events to use correct task implementation (#129891) 2025-02-09 18:36:16 +05:30
Kumar Aditya ce0cf7a73a
gh-129874: improve `test_tasks` in asyncio to use correct internal functions (#129890) 2025-02-09 13:02:11 +00:00
Kumar Aditya 09fe550ecc
gh-129874: improve asyncio tests to use correct internal functions (#129887) 2025-02-09 12:05:39 +00:00
Tian Gao 29f8a67ae0
Provide curframe_locals for backward compatibility but deprecate it (#125951) 2025-02-08 23:35:28 +00:00
Sam Gross c1f352bf08
gh-128657: Run test_hashlib with `--parallel-threads` (GH-129833)
* gh-128657: Run test_hashlib with `--parallel-threads`

This catches the race in `py_digest_by_name` that is fixed separately
in gh-128886.

* Adjust assertion order
2025-02-08 12:12:21 -08:00
Brian Ward 421ea1291d
gh-119349: Add ctypes.util.dllist -- list loaded shared libraries (GH-122946)
Add function to list the currently loaded libraries to ctypes.util

The dllist() function calls platform-specific APIs in order to
list the runtime libraries loaded by Python and any imported modules.
On unsupported platforms the function may be missing.


Co-authored-by: Eryk Sun <eryksun@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-02-08 14:02:36 +01:00
Barney Gale 707d066193
GH-129835: Yield path with trailing slash from `ReadablePath.glob('')` (#129836)
In the private pathlib ABCs, make `ReadablePath.glob('')` yield a path with
a trailing slash (if it yields anything at all). As a result, `glob()`
works similarly to `joinpath()` when given a non-magic pattern.

In the globbing implementation, we preemptively add trailing slashes to
intermediate paths if there are pattern parts remaining; this removes the
need to check for existing trailing slashes (in the removed `add_slash()`
method) at subsequent steps.
2025-02-08 06:47:09 +00:00
Barney Gale 718ab66299
GH-125413: Add `pathlib.Path.info` attribute (#127730)
Add `pathlib.Path.info` attribute, which stores an object implementing the `pathlib.types.PathInfo` protocol (also new). The object supports querying the file type and internally caching `os.stat()` results. Path objects generated by `Path.iterdir()` are initialised with status information from `os.DirEntry` objects, which is gleaned from scanning the parent directory.

The `PathInfo` protocol has four methods: `exists()`, `is_dir()`, `is_file()` and `is_symlink()`.
2025-02-08 01:16:45 +00:00
Irit Katriel a1417b211f
gh-100239: replace BINARY_SUBSCR & family by BINARY_OP with oparg NB_SUBSCR (#129700) 2025-02-07 22:39:54 +00:00
Sam Gross 2248a9c153
gh-129825: Skip test_faulthandler.test_register_chain under TSAN (gh-129827)
The test hangs when run under TSAN due to an interaction between TSAN's
signal interception and our attempt to call the previous signal handler.
2025-02-07 17:35:59 -05:00
Brandt Bucher 5fa7e1b7fd
GH-129715: Remove _DYNAMIC_EXIT (GH-129716) 2025-02-07 11:41:17 -08:00
Kumar Aditya 49bd47d5f1
improve `test_log_destroyed_pending_task` in asyncio (#129821) 2025-02-07 18:00:59 +00:00
Kumar Aditya f52a3a51eb
fix tests in `test_asyncio.test_tasks` to use correct `all_tasks` (#129815) 2025-02-07 21:46:26 +05:30
Ken Jin 175844713a
gh-128563: Move assignment of opcode into ifdef (GH-129803) 2025-02-07 21:11:57 +08:00
sobolevn ae132edc29
gh-129766: Fix crash on calling `warnings._release_lock` with no lock (#129771) 2025-02-07 12:59:52 +03:00
Forest 0fef47e5bb
gh-55454: Add IMAP4 IDLE support to imaplib (#122542)
* gh-55454: Add IMAP4 IDLE support to imaplib

This extends imaplib with support for the rfc2177 IMAP IDLE command,
as requested in #55454.  It allows events to be pushed to a client as
they occur, rather than having to continually poll for mailbox changes.

The interface is a new idle() method, which returns an iterable context
manager.  Entering the context starts IDLE mode, during which events
(untagged responses) can be retrieved using the iteration protocol.
Exiting the context sends DONE to the server, ending IDLE mode.

An optional time limit for the IDLE session is supported, for use with
servers that impose an inactivity timeout.

The context manager also offers a burst() method, designed for programs
wishing to process events in batch rather than one at a time.

Notable differences from other implementations:

- It's an extension to imaplib, rather than a replacement.
- It doesn't introduce additional threads.
- It doesn't impose new requirements on the use of imaplib's existing methods.
- It passes the unit tests in CPython's test/test_imaplib.py module
  (and adds new ones).
- It works on Windows, Linux, and other unix-like systems.
- It makes IDLE available on all of imaplib's client variants
  (including IMAP4_stream).
- The interface is pythonic and easy to use.

Caveats:

- Due to a Windows limitation, the special case of IMAP4_stream running
  on Windows lacks a duration/timeout feature. (This is the stdin/stdout
  pipe connection variant; timeouts work fine for socket-based
  connections, even on Windows.) I have documented it where appropriate.

- The file-like imaplib instance attributes are changed from buffered to
  unbuffered mode. This could potentially break any client code that
  uses those objects directly without expecting partial reads/writes.
  However, these attributes are undocumented. As such, I think (and
  PEP 8 confirms) that they are fair game for changes.
  https://peps.python.org/pep-0008/#public-and-internal-interfaces

Usage examples:

https://github.com/python/cpython/issues/55454#issuecomment-2227543041

Original discussion:

https://discuss.python.org/t/gauging-interest-in-my-imap4-idle-implementation-for-imaplib/59272

Earlier requests and suggestions:

https://github.com/python/cpython/issues/55454

https://mail.python.org/archives/list/python-ideas@python.org/thread/C4TVEYL5IBESQQPPS5GBR7WFBXCLQMZ2/

* gh-55454: Clarify imaplib idle() docs

- Add example idle response tuples, to make the minor difference from other
  imaplib response tuples more obvious.
- Merge the idle context manager's burst() method docs with the IMAP
  object's idle() method docs, for easier understanding.
- Upgrade the Windows note regarding lack of pipe timeouts to a warning.
- Rephrase various things for clarity.

* docs: words instead of <=

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* docs: improve style in an example

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* docs: grammatical edit

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* docs consistency

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* comment -> docstring

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* docs: refer to imaplib as "this module"

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* imaplib: simplify & clarify idle debug message

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* imaplib: elaborate in idle context manager comment

* imaplib: re-raise BaseException instead of bare except

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* imaplib: convert private doc string to comment

* docs: correct mistake in imaplib example

This is a correction to 8077f2eab2, which
changed a variable name in only one place and broke the subsequent
reference to it, departed from the naming convention used in the rest of
the module, and shadowed the type() builtin along the way.

* imaplib: simplify example code in doc string

This is for consistency with the documentation change in 8077f2eab2
and subsequent correction in 013bbf18fc.

* imaplib: rename _Idler to Idler, update its docs

* imaplib: add comment in Idler._pop()

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* imaplib: remove unnecessary blank line

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* imaplib: comment on use of unbuffered pipes

* docs: imaplib: use the reStructuredText :class: role

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Revert "docs: imaplib: use the reStructuredText :class: role"

This reverts commit f385e441df, because it
triggers CI failures in the docs by referencing a class that is
(deliberately) undocumented.

* docs: imaplib: use the reST :class: role, escaped

This is a different approach to f385e441df, which was reverted for
creating dangling link references.

By prefixing the reStructuredText role target with a ! we disable
conversion to a link, thereby passing continuous integration checks
even though the referenced class is deliberately absent from the
documentation.

* docs: refer to IMAP4 IDLE instead of just IDLE

This clarifies that we are referring to the email protocol, not the editor with the same name.

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>

* imaplib: IDLE -> IMAP4 IDLE in exception message

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* docs: imaplib idle() phrasing and linking tweaks

* docs: imaplib: avoid linking to an invalid target

This reverts and rephrases part of a3f21cd75b
which created links to a method on a deliberately undocumented class.
The links didn't work consistently, and caused sphinx warnings that
broke cpython's continuous integration tests.

* imaplib: update test after recent exception change

This fixes a test that was broken by changing an exception in
b01de95171

* imaplib: rename idle() dur argument to duration

* imaplib: bytes.index() -> bytes.find()

This makes it more obvious which statement triggers the branch.

* imaplib: remove no-longer-necessary statement

Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>

* docs: imaplib: concise & valid method links

The burst() method is a little tricky to link in restructuredText, due
to quirks of its parent class.  This syntax allows sphinx to generate
working links without generating warnings (which break continuous
integration) and without burdening the reader with unimportant namespace
qualifications.  It makes the reST source ugly, but few people read
the reST source, so it's a tolerable tradeoff.

* imaplib: note data types present in IDLE responses

* docs: imaplib: add comma to reST changes header

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* imaplib: sync doc strings with reST docs

* docs: imaplib: minor Idler clarifications

* imaplib: idle: emit (type, [data, ...]) tuples

This allows our iterator to emit untagged responses that contain literal
strings in the same way that imaplib's existing methods do, while still
emitting exactly one whole response per iteration.

* imaplib: while/yield instead of yield from iter()

* imaplib: idle: use deadline idiom when iterating

This simplifies the code, and avoids idle duration drift from time spent
processing each iteration.

* docs: imaplib: state duration/interval arg types

* docs: imaplib: minor rephrasing of a sentence

* docs: imaplib: reposition a paragraph

This might improve readability, especially when encountering Idler.burst()
for the first time.

* docs: imaplib: wrap long lines in idle() section

* docs: imaplib: note: Idler objects require 'with'

* docs: imaplib: say that 29 minutes is 1740 seconds

* docs: imaplib: mark a paragraph as a 'tip'

* docs: imaplib: rephrase reference to MS Windows

* imaplib: end doc string titles with a period

* imaplib: idle: socket timeouts instead of select()

IDLE timeouts were originally implemented using select() after
checking for the presence of already-buffered data.
That allowed timeouts on pipe connetions like IMAP4_stream.
However, it seemed possible that SSL data arriving without any
IMAP data afterward could cause select() to indicate available
application data when there was none, leading to a read() call
that would block with no timeout. It was unclear under what
conditions this would happen in practice. This change switches
to socket timeouts instead of select(), just to be safe.

This also reverts IMAP4_stream changes that were made to support IDLE
timeouts, since our new implementation only supports socket connections.

* imaplib: Idler: rename private state attributes

* imaplib: rephrase a comment in example code

* docs: imaplib: idle: use Sphinx code-block:: pycon

* docs: whatsnew: imaplib: reformat IMAP4.idle entry

* imaplib: idle: make doc strings brief

Since we generally rely on the reST/html documentation for details, we
can keep these doc strings short. This matches the module's existing doc
string style and avoids having to sync small changes between two files.

* imaplib: Idler: split assert into two statements

* imaplib: Idler: move assignment out of try: block

* imaplib: Idler: move __exit__() for readability

* imaplib: Idler: move __next__() for readability

* imaplib: test: make IdleCmdHandler a global class

* docs: imaplib: idle: collapse double-spaces

* imaplib: warn on use of undocumented 'file' attr

* imaplib: revert import reformatting

Since we no longer import platform or selectors, the original import
statement style can be restored, reducing the footprint of PR #122542.

* imaplib: restore original exception msg formatting

This reduces the footprint of PR #122542.

* docs: imaplib: idle: versionadded:: next

* imaplib: move import statement to where it's used

This import is only needed if external code tries to use an attribute
that it shouldn't be using. Making it a local import reduces module
loading time in supported cases.

* imaplib test: RuntimeWarning on IMAP4.file access

* imaplib: use stacklevel=2 in warnings.warn()

* imaplib test: simplify IMAP4.file warning test

* imaplib test: pre-idle-continuation response

* imaplib test: post-done untagged response

* imaplib: downgrade idle-denied exception to error

This makes it easier for client code to distinguish a temporary
rejection of the IDLE command from a server responding incorrectly to
IDLE.

* imaplib: simplify check for socket object

* imaplib: narrow the scope of IDLE socket timeouts

If an IDLE duration or burst() was in use, and an unsolicited response
contained a literal string, and crossed a packet boundary, and the
subsequent packet was delayed beyond the IDLE feature's time limit, the
timeout would leave the incoming protocol stream in a bad state (with
the tail of that response appearing where the start of a response is
expected).

This change moves the IDLE socket timeout to cover only the start
of a response, so it can no longer cause that problem.

* imaplib: preserve partial reads on exception

This ensures that short IDLE durations / burst() intervals
won't risk corrupting response lines that span multiple packets.

* imaplib: read/readline: save multipart buffer tail

For resilience if read() or readline() ever complete with more than one
bytes object remaining in the buffer. This is not expected to happen,
but it seems wise to be prepared for a future change making it possible.

* imaplib: use TimeoutError subclass only if needed

* doc: imaplib: elaborate on IDLE response delivery

* doc: imaplib: elaborate in note re: IMAP4.response

* imaplib: comment on benefit of reading in chunks

Our read() implementation designed to support IDLE replaces the one from
PR #119514, fixing the same problem it was addressing. The tests that it
added are preserved.

* imaplib: readline(): treat ConnectionError as EOF

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Martin Panter <vadmium@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-06 19:15:11 -08:00
Sam Gross a191d6f78e
gh-117657: Include all of test_free_threading in TSAN tests (#129749) 2025-02-07 00:37:05 +01:00
Sam Gross 4e3330f054
gh-117657: Skip tests that may cause stack overflows under TSan (#129751)
These tests crash under TSan due to stack overflows. Just skip them if
TSan is enabled.
2025-02-06 17:03:01 -05:00
Kumar Aditya 0d68b14a0d
gh-128002: use per threads tasks linked list in asyncio (#128869)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-02-06 19:51:07 +01:00
Ken Jin cb640b659e
gh-128563: A new tail-calling interpreter (GH-128718)
Co-authored-by: Garrett Gu <garrettgu777@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-02-06 23:21:57 +08:00
Sam Gross 555dc50c81
gh-129694: Add `--parallel-threads` TSAN job to CI (gh-129696)
For now, this just adds a single test suite to the TSAN CI to be run
with `--parallel-threads`.
2025-02-06 15:19:00 +00:00
Xuanteng Huang 55f17b77c3
gh-128714: Fix function object races in `__annotate__`, `__annotations__` and `__type_params__` in free-threading build (#129016) 2025-02-06 20:10:50 +05:30
Cody Maloney 5fb019fc29
gh-129559: Add `bytearray.resize()` (GH-129560)
Add bytearray.resize() which wraps PyByteArray_Resize.

Make negative size passed to resize exception/error rather than crash in optimized builds.
2025-02-05 11:33:17 -08:00
Victor Stinner e5c3b7e349
gh-129354: Cleanup test_coroutines (#129684)
Remove unused variables.
2025-02-05 11:43:46 +00:00
Victor Stinner a25042e6d2
gh-129354: Use PyErr_FormatUnraisable() function (#129523)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().

Update tests:

* test_coroutines
* test_exceptions
* test_generators
* test_struct
2025-02-05 10:31:59 +00:00
Sam Gross e5f10a7414
gh-127933: Add option to run regression tests in parallel (gh-128003)
This adds a new command line argument, `--parallel-threads` to the
regression test runner to allow it to run individual tests in multiple
threads in parallel in order to find multithreading bugs.

Some tests pass when run with `--parallel-threads`, but there's still
more work before the entire suite passes.
2025-02-04 17:44:59 -05:00
Serhiy Storchaka 979d766209
gh-128772: Fix pydoc for methods with __module__ is None (GH-129177) 2025-02-04 16:25:49 +02:00
Serhiy Storchaka 8b5c8508c7
gh-129350: Make tests for glob with trailing slash more strict (GH-129376)
Test that the trailing pathname separator is preserved.

Multiple trailing pathname separators are only preserved if the pattern
does not contain metacharacters, otherwise only one trailing pathname
separator is preserved. This is rather an implementation detail.
2025-02-04 16:24:22 +02:00
Mark Shannon 2effea4dab
GH-128682: Spill the stack pointer in labels, as well as instructions (GH-129618) 2025-02-04 12:18:31 +00:00
Yan Yanchii 0664c1af9b
gh-126835: Move constant subscript folding to CFG (#129568)
Move folding of constant subscription from AST optimizer to CFG.

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-02-04 10:10:55 +02:00
Mark Shannon 808071b994
GH-128682: Make `PyStackRef_CLOSE` escaping. (GH-129404) 2025-02-03 12:41:32 +00:00
Victor Stinner 218f205f20
gh-129354: Use PyErr_FormatUnraisable() function (#129524)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().

Update test_sqlite3 tests.

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2025-02-03 12:10:18 +00:00
Illia Volochii a33dcb9e43
gh-81340: Use copy_file_range in shutil.copyfile copy functions (GH-93152)
This allows the underlying file system an opportunity to optimise or avoid the actual copy.
2025-02-03 10:23:27 +00:00
Vojtěch Boček 4e38eeafe2
gh-115514: Fix incomplete writes after close while using ssl in asyncio(#128037)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-02 15:11:25 +00:00
Gregory P. Smith e1006ce1de
gh-119461: Restore the testSocket VSOCK skipUnless removed by PR #119465 (#129561)
Restore the skipUnless removed by #119465.

This test can only pass on virtual machines, not actual machines.

actual machines see:

```
    self.cli.connect((cid, VSOCKPORT))
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
OSError: [Errno 19] No such device
```

Reproduced on (Linux) Ubuntu 24.04.1 running 6.8.0-52-generic.
2025-02-01 20:46:56 -08:00
Victor Stinner 71ae93374d
gh-93649: Move _testcapi tests to specific files (#129544)
Move many functions from _testcapimodule.c into more specific files
in Modules/_testcapi/.

In moved code:

* Replace get_testerror() with PyExc_AssertionError.
* Replace raiseTestError() with
  PyErr_Format(PyExc_AssertionError, ...).
2025-02-01 13:39:16 +01:00
Kirill Podoprigora 7d0521d5fc
gh-126835: Move optimization of constant sequence creation from codegen to CFG (#129426)
Codegen phase has an optimization that transforms
```
LOAD_CONST x
LOAD_CONST y
LOAD_CONXT z
BUILD_LIST/BUILD_SET (3)
```
->
```
BUILD_LIST/BUILD_SET (0)
LOAD_CONST (x, y, z)
LIST_EXTEND/SET_UPDATE 1
```
This optimization has now been moved to CFG phase to make #128802 work.


Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Yan Yanchii <yyanchiy@gmail.com>
2025-02-01 11:39:44 +00:00
Seth Michael Larson d89a5f6a6e
gh-105704: Disallow square brackets (`[` and `]`) in domain names for parsed URLs (#129418)
* gh-105704: Disallow square brackets ( and ) in domain names for parsed URLs

* Use Sphinx references

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>

* Add mismatched bracket test cases, fix news format

* Add more test coverage for ports

---------

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-01-31 09:41:34 -08:00
Victor Stinner 60a85415ae
gh-93649: Add Modules/_testcapi/function.c file (#129521)
* Move PyFunction C API tests to a new file.
* Add Lib/test/test_capi/test_function.py.
* Move tests from test_capi.test_misc to test_capi.test_function.
2025-01-31 16:02:50 +01:00
Victor Stinner 5424e3b034
gh-93649: Add Modules/_testcapi/type.c file (#129516)
Move PyType C API tests to a new file.

Move following tests from test_capi.test_misc to test_capi.test_type:

* BuiltinStaticTypesTests
* test_get_type_name()
* test_get_base_by_token()
2025-01-31 15:03:54 +01:00
Victor Stinner 8b70ff5872
gh-93649: Move PyFrame C API tests to test_capi (#129512)
* Add Lib/test/test_capi/test_frame.py file.
* Move C API tests from test_frame to test_capi.test_frame.
* Add Modules/_testcapi/frame.c file.
* Move C API tests from _testcapimodule.c to frame.c
2025-01-31 13:51:58 +01:00
qm2k 22b2d37f42
gh-71494: string.Formatter: support keys/attributes in unnumbered fields (GH-21767) 2025-01-31 13:16:24 +01:00
Petr Viktorin 31c82c28f9
GH-128469: Revert "warn when libpython was loaded from outside the build directory (#128645)" (#129506) 2025-01-31 11:17:37 +00:00
Brandt Bucher 674befbd7b
GH-129386: Add `test.support.reset_code` (GH-129486) 2025-01-31 11:50:54 +01:00
Shantanu 8df5193d37
gh-127975: Avoid reusing quote types in ast.unparse if not needed (#127980) 2025-01-31 08:49:06 +00:00
Victor Stinner 95504f429e
gh-129354: Fix grammar in PyErr_FormatUnraisable() (#129475)
Replace "on verb+ing" with "while verb+ing".
2025-01-31 09:45:35 +01:00
donBarbos 510fefdc62
gh-127349: Add check for correct resizing in REPL (#127387) 2025-01-30 19:34:09 +00:00
Victor Stinner 4ca9fc08f8
gh-111495: Add PyFile tests (#129449)
Add tests for the following functions in test_capi.test_file:

* PyFile_FromFd()
* PyFile_GetLine()
* PyFile_NewStdPrinter()
* PyFile_WriteObject()
* PyFile_WriteString()
* PyObject_AsFileDescriptor()

Add Modules/_testlimitedcapi/file.c file.

Remove test_embed.StdPrinterTests which became redundant.
2025-01-30 18:05:32 +01:00
Victor Stinner 3bebe46d34
gh-128911: Add PyImport_ImportModuleAttr() function (#128912)
Add PyImport_ImportModuleAttr() and
PyImport_ImportModuleAttrString() functions.

* Add unit tests.
* Replace _PyImport_GetModuleAttr()
  with PyImport_ImportModuleAttr().
* Replace _PyImport_GetModuleAttrString()
  with PyImport_ImportModuleAttrString().
* Remove "pycore_import.h" includes, no longer needed.
2025-01-30 11:17:29 +00:00
Filipe Laíns 🇵🇸 a4722449ca
tests: add test.support.venv.VirtualEnvironmentMixin (#129461) 2025-01-30 03:32:24 +00:00
Filipe Laíns 🇵🇸 c931d75831
GH-127178: improve compatibility in `_sysconfig_vars_(...).json` (#128558) 2025-01-29 22:47:20 +00:00
Filipe Laíns 🇵🇸 29b3ce8355
GH-128469: warn when libpython was loaded from outside the build directory (#128645)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-01-29 22:35:55 +00:00
Tomas R. a1a4e9f39a
gh-125522: Fix bare except in `test_uuid` (#129018) 2025-01-29 20:59:45 +00:00
Hod fdcedfd3cf
gh-126400: Add TCP socket timeout to SysLogHandler to prevent blocking (GH-126716)
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
2025-01-29 19:37:43 +00:00
Brandt Bucher 002c4e2982
GH-129386: Use symbolic constants for specialization tests (GH-129415) 2025-01-29 10:49:58 -08:00
Irit Katriel 4815131910
gh-100239: specialize bitwise logical binary ops on ints (#128927) 2025-01-29 09:28:21 +00:00
Brandt Bucher 828b27680f
GH-126599: Remove the PyOptimizer API (GH-129194) 2025-01-28 16:10:51 -08:00
T. Wouters 5c930a26fb
gh-115999: Enable free-threaded specialization of LOAD_CONST (#129365)
Enable free-threaded specialization of LOAD_CONST.
2025-01-29 01:07:56 +01:00
Hood Chatham 789390872b
gh-127146: Skip test_readinto_non_blocking on Emscripten (#129421)
Skips an additional test due to non_blocking not working reliably on Emscripten.
2025-01-29 07:30:42 +08:00
Pieter Eendebak 64c417dee5
gh-112075: Remove critical section in dict.get (gh-129336)
The `dict.get` implementation uses `_Py_dict_lookup_threadsafe`, which is
thread-safe, so we remove the critical section from the argument clinic.

Add a test for concurrent dict get and set operations.
2025-01-28 21:55:45 +00:00
Barney Gale a4459c34ea
GH-127381: pathlib ABCs: remove `JoinablePath.match()` (#129147)
Unlike `ReadablePath.[r]glob()` and `JoinablePath.full_match()`, the
`JoinablePath.match()` method doesn't support the recursive wildcard `**`,
and matches from the right when a fully relative pattern is given. These
quirks means its probably unsuitable for inclusion in the pathlib ABCs,
especially given `full_match()` handles the same use case.
2025-01-28 20:22:55 +00:00
Yury Manushkin 4d0d24f6e3
gh-112064: Fix incorrect handling of negative read sizes in `HTTPResponse.read()` (#128270)
The parameter `amt` of `HTTPResponse.read()`, which could be a negative integer,
has not been handled before and led to waiting for the connection to close
for `keep-alive connections`. Now, this has been fixed, and passing negative values
to `HTTPResponse().read()` works the same as passing `None` value.
2025-01-28 11:37:32 +00:00
Hood Chatham 8e57877e3f
gh-127146: Update test skips for Emscripten 4.0.1 (#129375)
Updates the Emscripten test skips to reflect recent changes in Emscripten capabilities.
2025-01-28 01:05:21 +00:00
Sam Gross a6a8c6f86e
gh-128954: Reorder _PyInterpreterFrame fields for reduced memory usage (#128958)
This reduces the size of _PyInterpreterFrame by 8 bytes on 64-bit
platforms using the free threading build due to alignment requirements.

This allows for slightly more recursive calls into the interpreter (from
C), but `test_call.test_super_deep` still crashes.
2025-01-27 17:14:51 +00:00
Victor Stinner 8a5a18a36e
gh-129205: Modernize test_eintr (#129316)
* Use f-string.
* Fix grammar: replace 'datas' with 'data' (and replace 'data' with
  'item').
* Remove unused variables: 'pid' and 'old_mask'.
* Factorize test_read() and test_readinto() code.

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
2025-01-27 18:04:45 +01:00
Mark Shannon 75b4962157
GH-128914: Remove all but one conditional stack effects (GH-129226)
* Remove all 'if (0)' and 'if (1)' conditional stack effects

* Use array instead of conditional for BUILD_SLICE args

* Refactor LOAD_GLOBAL to use a common conditional uop

* Remove conditional stack effects from LOAD_ATTR specializations

* Replace conditional stack effects in LOAD_ATTR with a 0 or 1 sized array.

* Remove conditional stack effects from CALL_FUNCTION_EX
2025-01-27 16:24:48 +00:00