Commit graph

34551 commits

Author SHA1 Message Date
Alex Waygood
530ddd3e06
Revert "gh-118803: Remove ByteString from typing and collections.abc (#118804)" (#138990) 2025-09-16 16:48:19 +01:00
Jelle Zijlstra
6d6aba2523
gh-137226: Fix get_type_hints() on generic TypedDict with stringified annotations (#138953)
This issue appears specifically for TypedDicts because the TypedDict constructor
code converts string annotations to ForwardRef objects, and those are not evaluated
properly by the get_type_hints() stack because of other shenanigans with type
parameters.

This issue does not affect normal generic classes because their annotations are not
pre-converted to ForwardRefs.

The fix attempts to restore the pre- #137227 behavior in the narrow scenario where
the issue manifests. It mostly makes changes only in the paths accessible from get_type_hints(),
ensuring that newer APIs (such as evaluate_forward_ref() and annotationlib) are not affected
by get_type_hints()'s past odd choices. This PR does not fix issue #138949, an older issue I
discovered while playing around with this one; we'll need a separate and perhaps more
invasive fix for that, but it should wait until after 3.14.0.
2025-09-16 07:28:39 -07:00
Benjamin Johnson
ab6893ab5c
gh-138514: getpass: restrict echo_char to a single ASCII character (#138591)
This amends commit bf8bbe9a81 by
restricting `echo_char` in `getpass.getpass` to single printable
ASCII characters as it would be uncommon to use long strings or
multi-byte characters for keyboard feedback.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
2025-09-16 16:21:55 +02:00
AN Long
6393068bde
fix some typos (#138977) 2025-09-16 18:33:39 +05:30
ivan
01cc53295c
Synced docs and docstring for sysconfig.get_platform (#135530)
Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
Co-authored-by: Ned Deily <nad@python.org>
2025-09-16 12:16:48 +01:00
yihong
b9dbf6acb3
gh-135329: prevent infinite traceback loop on Ctrl-C for strace (GH-138133)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: dura0ok <slpmcf@gmail.com>
Co-authored-by: graymon <greyschwinger@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-09-16 12:39:03 +02:00
Cody Maloney
ed75160b73
gh-138013: Remove load_tests in test_io.test_general (#138771)
Rely on default test discovery.

Validation:
```bash
 # Run before commit
./python -m test test_io -uall,walltime,largefile,cpu,extralargefile -M25G -o --fail-env-changed -j0 --list-cases | sort > old_cases.txt
 # Run after commit
./python -m test test_io -uall,walltime,largefile,cpu,extralargefile -M25G -o --fail-env-changed -j0 --list-cases | sort > new_cases.txt

diff new_cases.txt old_cases.
 # <outputs no changes in case list>
```
2025-09-16 10:37:28 +02:00
Sam Gross
90fe3250f8
gh-137433: Fix deadlock with stop-the-world and daemon threads (gh-137735)
There was a deadlock originally seen by Memray when a daemon thread
enabled or disabled profiling while the interpreter was shutting down.
I think this could also happen with garbage collection, but I haven't
seen that in practice.

The daemon thread could be hung while trying acquire the global rwmutex
that prevents overlapping global and per-interpreter stop-the-world events.
Since it already held the main interpreter's stop-the-world lock, it
also deadlocked the main thread, which is trying to perform interpreter
finalization.

Swap the order of lock acquisition to prevent this deadlock.
Additionally, refactor `_PyParkingLot_Park` so that the global buckets
hashtable is left in a clean state if the thread is hung in
`PyEval_AcquireThread`.
2025-09-16 09:21:58 +01:00
Loïc Simon
537133d2b6
gh-69605: Hardcode some stdlib submodules in PyREPL module completion (os.path, collections.abc...) (GH-138268)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-09-15 18:51:34 +02:00
Serhiy Storchaka
29d026f93e
gh-37817: Allow assignment to __bases__ of direct subclasses of builtin classes (GH-137585) 2025-09-15 16:40:28 +00:00
yihong
8ef7735c53
gh-128636: Fix crash in PyREPL when os.environ is overwritten with an invalid value for macOS (GH-138089)
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-09-15 18:26:23 +02:00
00ll00
26cfb17942
gh-138239: Fix incorrect highlighting of "type" in type statements in the REPL (GH-138241)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-09-15 18:21:41 +02:00
Savannah Bailey
9c9a0f7da7
GH-132732: Use pure op machinery to optimize various instructions with _POP_TOP and _POP_TWO (#137577) 2025-09-15 16:29:45 +01:00
Serhiy Storchaka
a003112821
gh-138712: Add os.NODEV (GH-138728) 2025-09-15 14:36:32 +00:00
László Kiss Kollár
3e06cfcaee
gh-135953: Reduce memory usage of stack collectors (#138875)
The stack collector base class keeps all frames until export() is
called, which causes significant unnecessary memory usage. Instead, we
can process the frames on the fly in the collect call by dispatching the
aggregation logic to the subclass through the process_frames method.

Co-authored-by: Pablo Galindo Salgado <pablogsal@gmail.com>
2025-09-14 23:47:14 +01:00
Barney Gale
805e3368d6
GH-128520: pathlib ABCs: improve protocol for 'openable' objects (#134101)
Rename `pathlib._os.magic_open()` to `vfsopen()`. The new name is a bit
less abstract, and it aligns with the `vfspath()` method added in 5dbd27d.

Per discussion on discourse[^1], adjust `vfsopen()` so that the following
methods may be called:

- `__open_reader__()`
- `__open_writer__(mode)`
- `__open_updater__(mode)`

These three methods return readable, writable, and full duplex file objects
respectively. In the 'writer' method, *mode* is either 'a', 'w' or 'x'. In
the 'updater' method, *mode* is either 'r' or 'w'.

In the pathlib ABCs, replace `ReadablePath.__open_rb__()` with
`__open_reader__()`, and replace `WritablePath.__open_wb__()` with
`__open_writer__()`.

[^1]: https://discuss.python.org/t/open-able-objects/90238

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-09-12 22:25:18 +01:00
Christoph Walcher
220c0a8156
gh-138804: Check type in shlex.quote (GH-138809) 2025-09-12 14:26:21 -04:00
Victor Stinner
c3fca5d478
gh-129813, PEP 782: Add PyBytesWriter_Format() (#138824)
Modify PyBytes_FromFormatV() to use the public PyBytesWriter API
rather than the _PyBytesWriter private API.
2025-09-12 14:21:57 +02:00
ivonastojanovic
419441a6e1
Improve permission error messages in pdb and asyncio.tools (#134290) 2025-09-12 12:54:04 +01:00
Victor Stinner
adb414044f
gh-129813, PEP 782: Add PyBytesWriter C API (#138822) 2025-09-12 13:41:59 +02:00
jxes993409
492941459a
gh-138163: skip failures if tests are run with SCHED_BATCH on glibc (GH-138576) 2025-09-12 11:37:53 +02:00
Jan-Eric Nitschke
44991619ba
gh-138669: Increase test coverage for difflib (GH-138670) 2025-09-12 11:33:38 +02:00
Chris Eibl
4f3cab96c1
gh-138801: re-enable pyrepl tests on Windows (#138802) 2025-09-12 10:47:43 +03:00
Benjamin Peterson
5bd4bf04c4
closes gh-138706: update Unicode to 17.0.0 (#138719) 2025-09-11 09:58:39 -07:00
Alper
32e1e0699f
gh-116738: add multi-threaded tests for resource module on free-threading builds (#138504) 2025-09-11 19:08:08 +05:30
Cody Maloney
101172486f
gh-138013: Move I/O test infrastructre to test_io.utils (#138475)
This moves test support code to `test_io.utils` via copy/paste
code movement then adjusts imports as needed
(remove unneded + add all required).
2025-09-11 12:45:30 +02:00
Peter Bierma
1da989be74
gh-138479: Ensure that __typing_subst__ returns a tuple (GH-138482)
Raise an exception if __typing_subst__ returns a non-tuple object.

---------

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-11 06:39:09 -04:00
Sergey B Kirpichev
011179a79a
gh-71810: Fix corner case (length==0) for int.to_bytes() (#138739)
```pycon
>>> (0).to_bytes(0, 'big', signed=True)
b''
>>> (-1).to_bytes(0, 'big', signed=True)  # was b''
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    (-1).to_bytes(0, 'big', signed=True)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
OverflowError: int too big to convert
```

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-09-11 12:30:53 +02:00
Stephen Morton
859aecc33b
gh-138432: Improved invalid path checking in zoneinfo.reset_tzpath() (GH-138433)
* Improve error messages for path-like relative paths and path-like bytes paths.
* TZPATH is now always a tuple of strings.
2025-09-11 10:08:53 +03:00
Jelle Zijlstra
7a6fd4a45d
gh-138349: Fix crash when combining module-level annotation and listcomp (#138363) 2025-09-10 15:18:39 +02:00
sobolevn
f5fa336579
gh-138729: Cover inspect.formatannotationrelativeto with tests (#138730) 2025-09-10 16:06:16 +03:00
sobolevn
cf8f36fe0a
gh-138716: Fix assert a := b syntax error message (#138718) 2025-09-10 16:05:16 +03:00
Dung Nguyen
1ce05537a3
gh-138008: Fix segfaults in _ctypes due to invalid argtypes (GH-138285)
Signed-off-by: Nguyen Viet Dung <29406816+magnified103@users.noreply.github.com>
Signed-off-by: Nguyen Viet Dung <dung@ekluster.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Yongzi Li <204532581+Yzi-Li@users.noreply.github.com>
2025-09-10 14:01:19 +02:00
Bénédikt Tran
d6d054853d
gh-137371: refactor and fortify test.support.hashlib_helper (#137375) 2025-09-10 09:14:38 +02:00
László Kiss Kollár
137519a38c
gh-135953: Add flamegraph reporter to sampling profiler (#138715) 2025-09-09 23:06:45 +01:00
sobolevn
6bc65c30ff
gh-136616: Improve assert syntax error messages (#136653) 2025-09-09 23:26:22 +03:00
Serhiy Storchaka
af58a6f883
gh-88886: Remove excessive encoding name normalization (GH-137167)
The codecs lookup function now performs only minimal normalization of
the encoding name before passing it to the search functions:
all ASCII letters are converted to lower case, spaces are replaced
with hyphens.

Excessive normalization broke third-party codecs providers, like
python-iconv.

Revert "bpo-37751: Fix codecs.lookup() normalization (GH-15092)"

This reverts commit 20f59fe1f7.
2025-09-09 21:07:21 +03:00
Jeffrey Bosboom
d4825ac27c
gh-138535: Optimize fill_time for typical timestamps (#138537)
While file timestamps can be anything the file system can store, most
lie between the recent past and the near future.  Optimize fill_time()
for typical timestamps in three ways:

- When possible, convert to nanoseconds with C arithmetic.
- When using C arithmetic and the seconds member is not required (for
  st_birthtime), avoid creating a long object.
- When using C arithmetic, reorder the code to avoid the null checks
  implied in Py_XDECREF().

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-09-09 11:05:54 +02:00
Donghee Na
5edfe55acf
gh-137838: Fix JIT trace buffer overrun by increasing possible exit stubs (gh-138177) 2025-09-09 09:51:08 +09:00
Pablo Galindo Salgado
03ee060ec8
gh-138385: Sample all interpreters in the tachyon profiler (#138398) 2025-09-09 00:41:08 +01:00
Victor Stinner
01895d233b
gh-137242: Add a --no-randomize option, and use it in Android CI (#138649)
Adds a --no-randomize option to the CI runner, so that randomisation can be easily
disabled for --fast-ci and --slow-ci configurations on single-threaded testing platforms
like Android, iOS, and Emscripten.

---------

Co-authored-by: Malcolm Smith <smith@chaquo.com>
2025-09-09 06:45:42 +08:00
Dino Viehland
1561385863
gh-138679: Opcodes which consume no inputs should indicate they produced the val… (#138678)
Opcodes which consume no inputs should indicate they produced the value, not an arbitrary local
2025-09-08 13:53:12 -07:00
Adam Turner
5443b9e52f
gh-133143: Condense the implementation for `sys.abi_info` (#138672) 2025-09-08 19:21:28 +00:00
Bruce Merry
7d435cfde6
gh-136234: Fix SelectorSocketTransport.writelines to be robust to connection loss (#136743) 2025-09-08 21:39:52 +05:30
Klaus Zimmermann
1acb718ea2
gh-133143: Add sys.abi_info (GH-137476)
This makes information about the interpreter ABI more accessible.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-08 14:35:44 +00:00
Christoph Walcher
59edf12705
gh-57911: Fix failing symlink test in tarfile (GH-138626) 2025-09-08 15:42:54 +02:00
yihong
7a3bca50e0
gh-138318, PyREPL: builtins should not be highlighted when used as attribute names (#138319) 2025-09-08 14:04:22 +01:00
Adam Turner
057ee17410
gh-136264: Fix `--relative-paths` for PEP 739's build-details.json (#138510)
* KeyError is not raised for defaultdict
* Fix relative paths on different drives on Windows
* Add a round-trip test

Co-authored-by: Itamar Oren <itamarost@gmail.com>
2025-09-08 10:14:05 +01:00
Ron Frederick
6401823db3
gh-138252: Add support in SSL module for getting and setting TLS signature algorithms (#138269)
The signature algorithms allowed for certificate-based client authentication or
for the server to complete the TLS handshake can be defined on a SSL context via
`ctx.set_client_sigalgs()` and `ctx.set_server_sigalgs()`.

With OpenSSL 3.4 or later, the list of available TLS algorithms can be retrieved
by `ssl.get_sigalgs()`.

With OpenSSL 3.5 or later, the selected signature algorithms can be retrieved from
SSL sockets via `socket.client_sigalg()` and `socket.server_sigalg()`.

This commit also partially amends 377b787618
by using `PyUnicode_DecodeFSDefault` instead of `PyUnicode_DecodeASCII` in
`_ssl._SSLContext.get_groups`, so that functions consistently decode strings
obtained from OpenSSL.

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-09-08 08:36:12 +00:00
sobolevn
b0420b505e
gh-105487: Fix __dir__ entries of GenericAlias (#138578)
Co-authored-by: Emma Smith <emma@emmatyping.dev>
2025-09-08 00:33:24 +03:00