Commit graph

34531 commits

Author SHA1 Message Date
Peter Bierma
d06113c7a7
gh-112729: Correctly fail when the process is out of memory during interpreter creation (GH-139164) 2025-09-19 10:41:09 -04:00
Lisa Roach
2fd43a1ffe
gh-138310: Adds sys.audit event for import_module (#138311)
* Updates sys.audit calls for imports to include import_module
* Adds unit tests for existing and new functionality
2025-09-19 06:21:42 -07:00
Serhiy Storchaka
7257b24140
gh-139076: Fix regression in pydoc not showing extension functions (GH-139077)
Fix a bug in the pydoc module that was hiding functions in a Python
module if they were implemented in an extension module and the module did
not have __all__.
2025-09-19 15:54:06 +03:00
Peter Bierma
9243a4b933
gh-126016: Remove bad assertion in PyThreadState_Clear (GH-139158)
In the _interpreters module, we use PyEval_EvalCode() to run Python code in another interpreter. However, when the process receives a KeyboardInterrupt, PyEval_EvalCode() will jump straight to finalization rather than returning. This prevents us from cleaning up and marking the thread as "not running main", which triggers an assertion in PyThreadState_Clear() on debug builds. Since everything else works as intended, remove that assertion.
2025-09-19 12:17:05 +00:00
Gordon P. Hemsley
e3d9bd6be3
gh-81148: Eliminate unnecessary check in _strptime when determining AM/PM (#13428)
* bpo-36967: Eliminate unnecessary check in _strptime when determining AM/PM

* Pauls suggestion to refactor test

* Fix test

---------

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2025-09-19 10:23:12 +00:00
Semyon Moroz
495f589363
gh-121237: Add %:z directive to datetime.strptime (#136961) 2025-09-19 10:25:31 +01:00
da-woods
ac5c5d42a2
gh-119494: Fix error messages for deleting/setting type attributes (#119495) 2025-09-18 22:08:49 +01:00
Peter Bierma
3eec897752
gh-136003: Skip non-daemon threads when exceptions occur during finalization (GH-139129)
During finalization, we need to mark all non-daemon threads as daemon to quickly shut down threads when sending CTRL^C to the process. This was a minor regression from GH-136004.
2025-09-18 16:04:01 -04:00
Alex Waygood
293b05c09b
gh-118803: Make ByteString deprecations louder; remove ByteString from typing.__all__ and collections.abc.__all__ (#139127) 2025-09-18 18:58:16 +00:00
Nicholas Tindle
0f27e10204
gh-137976: Explicitly exclude localtime from available_timezones (#138012)
* fix: available_timezones is reporting an invalid IANA zone name

* 📜🤖 Added by blurb_it.

* correct rst format for backticks

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2025-09-18 17:32:14 +01:00
Adam Turner
1ebd726c9b
gh-64490: Argument Clinic: Add support for `**kwds` (#138344)
This adds a scaffold of support, initially only working with
strictly positional-only arguments. The FASTCALL calling
convention is not yet supported.
2025-09-18 13:31:42 +00:00
Victor Stinner
6504f20cce
gh-135755: Make Py_TAIL_CALL_INTERP macro private (#138981)
Rename Py_TAIL_CALL_INTERP to _Py_TAIL_CALL_INTERP.
2025-09-18 14:33:07 +02:00
Peter Bierma
2191497933
gh-136003: Execute pre-finalization callbacks in a loop (GH-136004) 2025-09-18 08:29:12 -04:00
Peter Bierma
571210b8f3
gh-135729: Store reference to globals in Interpreter._decref (GH-139104) 2025-09-18 11:17:51 +00:00
Petr Viktorin
36ec60fb43
gh-138970: Adjust tests for pegen rule flags (#139107) 2025-09-18 12:08:44 +01:00
Malcolm Smith
0ac377ff23
Make Android streams respect the unbuffered (-u) option (#138806)
Android pipes stdout/stderr to the log, which means every write to the log
becomes a separate log line. As a result, most practical uses of stdout/stderr
should be buffered; but it doesn't hurt to preserve unbuffered handling in case
it's useful.
2025-09-18 11:41:21 +01:00
Cody Maloney
db68bfc771
gh-138720: Make Buffered closed check match flush (GH-138724)
In `_io__Buffered_flush_impl` the macro `CHECK_CLOSED` is used to check
the `buffered*` is in a good state to be flushed. That differs slightly
from `buffered_closed`.

In some cases, that difference would result in `close()` thinking the
file needed to be flushed and closed while `flush()` thought the file
was already closed.

This could happen during GC and would result in an unraisable exception.
2025-09-18 12:02:29 +02:00
Mark Shannon
3b83257366
GH-138378: Move globals-to-consts pass into main optimizer pass (GH-138379) 2025-09-18 10:09:59 +01:00
Raymond Hettinger
c25400a4b6
Revert gh-139075. The sumprod fix needs more work. (gh-139092) 2025-09-18 02:05:27 -05:00
Pablo Galindo Salgado
0ce9fb7e3b
gh-138970: Add general metadata system to the peg generator (#138971) 2025-09-18 02:17:04 +01:00
Raymond Hettinger
b485e50fde
gh-139074: Fix missing high precision case in sumprod() (gh-139075) 2025-09-17 16:50:15 -05:00
Denis Sergeev
5a15e73789
gh-138813: Fix mutable default kwargs={} in multiprocessing BaseProcess and DummyProcess to use None (GH-138814)
* gh-138813: Default `BaseProcess` `kwargs` to `None` (#138814)

Set `BaseProcess.__init__(..., kwargs=None)` and initialize `kwargs` with
`dict(kwargs) if kwargs else {}`. This avoids a shared mutable default and
matches threading.Thread behavior.

Co-authored-by: Dmitrii Chuprov <cheese@altlinux.org>

* DummyProcess kwargs=None (which threading.Thread accepts properly)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-09-17 14:45:52 -07:00
Stefan Tatschner
a9b6b09141
gh-86819: Add ISO-TP CAN socket constants (#23794)
Co-authored-by: Stefan Tatschner <stefan@rumpelsepp.org>
Co-authored-by: Patrick Menschel <menschel.p@posteo.de>
2025-09-17 17:18:04 +00:00
Dino Viehland
e92599e677
gh-138714: Don't assume next block has instructions when propagating line numbers (#138770)
Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
2025-09-17 09:52:56 -07:00
Peter Bierma
a64881363b
gh-128639: Don't assume one thread in subinterpreter finalization with fixed daemon thread support (GH-134606)
This reapplies GH-128640.
2025-09-17 11:14:19 -04:00
Petr Viktorin
5df6a568e1
gh-107862: Add property-based round-trip tests for base64 (#119406)
* Add property-based tests to test_base64

* Allow multiple positional arguments in @hypothesis.example stub

* Simplify the altchars strategy
2025-09-17 13:40:35 +00:00
Bénédikt Tran
3a04be986a
gh-76760: test that uuid.uuid1() sets the version field (#139033) 2025-09-17 13:31:51 +00:00
Gyeongjae Choi
218b8dbc78
gh-99948: Support ctypes.util.find_library in emscripten environment (#138519)
Adds support for ctypes loading .so files directly.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2025-09-17 10:17:56 +00:00
Serhiy Storchaka
a1cf6e92b6
gh-71679: Share the repr implementation between bytes and bytearray (GH-138181)
This allows to use the smart quotes algorithm in the bytearray's repr.
2025-09-17 11:10:29 +03:00
Serhiy Storchaka
cf9ef73121
gh-134716: Support regular expressions in -W and PYTHONWARNINGS (GH-138149) 2025-09-16 17:06:44 +00:00
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