Commit graph

57343 commits

Author SHA1 Message Date
Xiao Yuan
7edcaedc53
gh-118158: Fix missing newline in py_compile CLI error output (#149008)
Restore trailing newline in error messages from `python -m py_compile`,
lost when `main()` was refactored to use argparse.
2026-06-16 09:41:52 -07:00
Hugo van Kemenade
627adb517f
gh-151428: Remove unused imports from stdlib (#151478) 2026-06-16 19:31:01 +03:00
Victor Stinner
b16d23fc9f
gh-151218: Replace sys.flags in PyConfig_Set() (#151402)
PyConfig_Set() and sys.set_int_max_str_digits() now replace
sys.flags (create a new object), instead of modifying sys.flags in-place.

Modifying sys.flags in-place can lead to data races when multiple
threads are reading or writing sys.flags in parallel.

Use _Py_atomic functions to get and set max_str_digits members.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-16 16:17:33 +00:00
Itamar Oren
2ce260033b
gh-151519: Check effective gid in _test_all_chown_common group-0 guard (#151521)
The guard that skips the "chown to gid 0 should fail" assertion used
only `os.getgroups()` (supplementary groups). The kernel also accepts
the effective/filesystem gid for chown, so when a process runs with
egid 0 and a non-zero uid (common in containers and user namespaces),
chown(-1, 0) succeeds and the assertion spuriously fails.

Add an `os.getegid() != 0` check alongside the existing
`0 not in os.getgroups()` guard.
2026-06-16 18:05:21 +02:00
dev
0777a58d80
gh-150771: Fix email serialization for shift_jis and euc-jp (GH-151120)
Encode the payload with output_charset instead of input_charset.
2026-06-16 14:49:54 +03:00
Itamar Oren
11f032f904
gh-151522: Guard against None transport in slow-socket SSL test (#151523) 2026-06-15 21:51:39 -07:00
Hood Chatham
8646385076
gh-151422: Don't link libffi into _ctypes_test.so (#151423)
_ctypes_test doesn't use libffi directly, and linking it into the module 
causes emscripten tests to fail.
2026-06-16 06:16:16 +08:00
Langyan
5ea1e907d1
gh-151128: Improve SyntaxError message for cross language keywords (GH-151129) 2026-06-15 20:55:57 +03:00
Weilin Du
585e14c7d3
gh-140145: Use repr of the key in zoneinfo "No time zone found" error (#140433)
Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-15 17:11:10 +01:00
Xiao Yuan
46107ad9da
gh-92455: Respect case-sensitive mimetype suffixes (GH-148782) 2026-06-15 15:05:29 +00:00
Nick Begg
35ce2e5f98
gh-148853: Catch PermissionError in test in_systemd_nspawn_sync_suppressed() (#148854)
/run/ on my FreeBSD install is not readable causing failing test.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2026-06-15 16:25:08 +02:00
Victor Stinner
18f3ffec43
gh-149671: Restore compatibility with setuptools -nspkg.pth files in site module (#151319)
Inject the "sitedir" variable in the frame which executes ".pth" code.
2026-06-15 08:29:52 +00:00
Stan Ulbrych
d63c9940f0
gh-130197: Test pygettext's --version CLI option (#133022) 2026-06-14 19:17:45 +00:00
Bartosz Sławecki
a7007322c2
gh-151390: Colorize match + and match - in the REPL (#151391) 2026-06-14 19:06:30 +03:00
Bartosz Sławecki
f1a5f68e37
gh-151461: Fix encoding-related exception handling in file tokenizer (GH-151462) 2026-06-14 12:33:03 +00:00
Gregory P. Smith
e91f68ab40
Skip test_highly_nested_objects_decoding during the PGO profile task. (GH-151460)
Since the recursion guard tracks real C-stack bounds (gh-91079), this test
asserts that 500k nesting levels overflow the stack margin. On a 64 MiB stack
(some Nix build envs use one that large), the optimized interpreter uses ~160
bytes/level (raises at ~420k levels) so the assertion holds with only ~16%
margin; the PGO *instrumented* stage inlines less, its per-level scanner frames
are smaller, and the 500k-deep decode completes -- "RecursionError not raised"
fails the profile run and aborts `make profile-opt`. Upstream's
skip_if_unlimited_stack_size (gh-143460) only covers RLIM_INFINITY, not
large-finite stacks like ours.

We could also keep playing whack a mole and raise the 500k to a much larger
number... but there's little value in PGO training on this test anyways.
2026-06-14 12:29:26 +00:00
Ivy Xu
a7885b46f1
gh-151428: Remove unused imports in the stdlib (#151440) 2026-06-14 13:00:28 +01:00
Stan Ulbrych
e933987688
gh-77328: Update base64 module RFC references to RFC 4648 (#151275) 2026-06-13 12:21:54 +00:00
Daniel Shields
3c00ebc2bb
gh-101267: ProcessPoolExecutor no longer shares 1 BrokenProcessPool exception among all failed futures (GH-101268)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-06-13 01:23:39 -07:00
Ivy Xu
507250b750
Correct the docstring of logging.config (GH-151353) 2026-06-11 19:29:20 +01:00
Serhiy Storchaka
d2e27aca4b
gh-150285: Fix overflow in too long lines for class data in pydoc (GH-151366)
Use all available space (80 columns) for formatting reprs
of module and class data, but ensure that they do not overflow.
2026-06-11 20:50:00 +03:00
Aniket
402668b2b1
gh-138991: Update dataclass documentation for new eq behavior in Python 3.13 (#139007)
And add tests.

Co-authored-by: Victor Stinner <vstinner@python.org>
2026-06-11 17:15:29 +00:00
Kumar Aditya
6112d70abe
gh-151228: fix data race on clearing embedded dict values (#151330) 2026-06-11 21:37:00 +05:30
Victor Stinner
0bbde07a0b
gh-150397: Fix pyexpat bigmem test (#151329)
Add missing parameter (size).
2026-06-11 16:45:44 +02:00
Stan Ulbrych
4b44b1e1fd
gh-151238: Check for _get_resized_exprs failure in _PyPegen_{joined,template}_str (#151259) 2026-06-11 15:26:46 +01:00
Serhiy Storchaka
0066fd73a2
gh-150285: Suppress showing the __getstate__() comment in the help for dataclasses (GH-151328) 2026-06-11 15:23:19 +03:00
Timofei
a05b9cde93
gh-151179: Fix pidfd leak in asyncio _PidfdChildWatcher (#151186) 2026-06-11 11:43:46 +00:00
Victor Stinner
72e7eddce6
gh-123619: Fix PyUnstable_Object_EnableDeferredRefcount() (#151260)
Return 0 if the object is not tracked by the GC.
2026-06-11 12:55:13 +02:00
Victor Stinner
d87d772873
gh-151284: Fix test_capi on UBSan (#151286)
Comment two checks relying on undefined behavior in
test_fromwidechar() of test_capi.

Enable test_capi in GitHub Action "Reusable Sanitizer".
2026-06-11 10:55:09 +00:00
tonghuaroot (童话)
84a322aa15
gh-151295: Fix use-after-free in bytes.join()/bytearray.join() via re-entrant __buffer__ (GH-151296) 2026-06-11 07:51:43 +00:00
Victorien
871047dbb8
gh-139819: Use builtin sentinel in rlcompleter (GH-151222)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2026-06-10 13:43:09 -07:00
Victor Stinner
e60c42dc3f
gh-151278: Fix test_faulthandler on UBSan (#151279)
* Py_FatalError() no longer calls _PyFaulthandler_Fini() if it
  doesn't hold the GIL.
* Skip test_faulthandler tests raising signals if run with UBSan.
* Enable test_faulthandler in GitHub Action "Reusable Sanitizer".
2026-06-10 21:39:03 +02:00
Victor Stinner
7b6e98911e
gh-151253: Dump the Python path configuration on _PyCodec_InitRegistry() failure (#151250)
If "import encodings" fails at Python startup, dump the Python path
configuration to help users debugging their configuration. The
encodings module is the first module imported during Python startup.
2026-06-10 18:43:38 +02:00
tonghuaroot (童话)
896f7fdc7d
gh-143988: Fix re-entrant mutation crashes in socket sendmsg/recvmsg_into (#143987)
Fix crashes in socket.sendmsg() and socket.recvmsg_into() that could
occur if buffer sequences are mutated re-entrantly during argument
parsing via __buffer__ protocol callbacks.

The bug occurs because:

1. PySequence_Fast() returns the original list object when the input
   is already a list (not a copy).
2. During iteration, PyObject_GetBuffer() triggers __buffer__
   callbacks which may clear the list.
3. Subsequent iterations access invalid memory (heap OOB read).

The fix replaces PySequence_Fast() with PySequence_Tuple() which
always creates a new tuple, ensuring the sequence cannot be mutated
during iteration.

Co-authored-by: tonghuaroot <23011166+tonghuaroot@users.noreply.github.com>
2026-06-10 13:03:49 +00:00
Lukas Geiger
f2a0f82282
gh-150988: Fix refleak in OSError when attrs are set before super().__init__() (#150990)
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-06-10 12:27:11 +00:00
Serhiy Storchaka
3ca93ab198
Add yet one assertion in test_set_text_charset_cp949 (GH-151224)
Check bytes(m), not only str(m).
2026-06-10 14:36:14 +03:00
stratakis
3a08e93739
gh-98894: Fix DTrace test_check_probes for shared builds (#151122)
When building with --enable-shared, the SystemTap/DTrace notes
live in libpython. Add detection logic to be used by readelf.

Force the C locale on readelf output.
2026-06-10 13:08:25 +02:00
Serhiy Storchaka
16f71bda3f
gh-150285: Wrap long single-line summary in text output in pydoc (GH-151081) 2026-06-10 13:44:35 +03:00
Serhiy Storchaka
ca32ebf793
gh-80384: Check that callback is callable at weak reference creation (GH-151145)
* Python functions weakref.ref() and weakref.proxy() now raise TypeError
  if the callback argument is not callable or None.
* C functions PyWeakref_NewRef() and PyWeakref_NewProxy() now raise TypeError
  if the callback argument is not callable, None, or NULL.

Co-authored-by: Maxwell Bernstein <emacs@fb.com>
2026-06-10 13:34:55 +03:00
Harjoth Khara
7a014f44c3
gh-109940: Respect VIRTUAL_ENV_DISABLE_PROMPT in activate.bat (GH-151215) 2026-06-10 09:48:16 +01:00
Bartosz Sławecki
ff64d8de66
gh-145239: Colorize case + in the REPL (#150979) 2026-06-10 09:36:50 +03:00
Bartosz Sławecki
ce916dc506
gh-150700: Fix class-scope inline comprehensions when nested scopes reference __class__ and friends (#150735)
* Fix class-scope inline comprehensions when nested scopes reference `__class__` and friends

In `inline_comprehension()`, when `__class__` / `__classdict__` /
`__conditional_annotations__` appears as `FREE` in a comprehension's
symbol table because a nested scope captured it (e.g. nested lambdas),
this name is still discarded from `comp_free` unconditionally.

This prevents `drop_class_free()` from seeing it, so the appropriate
`ste_needs_(...)` flag is never set on the enclosing class.
That leads to `codegen_make_closure()` throwing `SystemError` when it
couldn't find `__class__` / `__classdict__` /
`__conditional_annotations__` in the class's cellvars.

From now on we just discard from `comp_free` when no child scope
(e.g. a lambda) still needs the name as `FREE`. When a child scope does
need it, keep it in `comp_free` so `drop_class_free()` can set the
appropriate flag and the class creates the implicit cell.

* Fix tests

* Fix typo

* Fix formatting

* Add test checking validity of `__class__` returned

* Prefer 'used' to 'deferred'
2026-06-09 15:22:13 -07:00
Peter
81c1cdcf4a
gh-139819: rlcompleter – avoid suggesting attributes not accessible on instances (GH-139820)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2026-06-09 11:00:23 -07:00
Serhiy Storchaka
0fa06f4d7f
gh-150285: Fix too long docstrings in the concurrent package (GH-151076) 2026-06-09 19:14:10 +03:00
Serhiy Storchaka
ed2b04248a
gh-150285: Fix too long docstrings in the asyncio package (GH-151074) 2026-06-09 19:13:34 +03:00
Robsdedude
b2e2cd3912
gh-150898: Assume OpenSSL supports keylogging (#150870)
Since version 3.10, CPython requires OpenSSL 1.1.1 or higher.
Therefore, support for keylogging can be assumed.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-06-09 16:37:38 +02:00
sobolevn
9fdbade99e
gh-151039: Fix a crash when _datetime types outlive _datetime module (#151044) 2026-06-09 11:44:37 +00:00
Serhiy Storchaka
c3cd75afdf
gh-151130: Add more tests for PyWeakref_* C API (GH-151131) 2026-06-09 11:11:17 +00:00
Cody Maloney
db4b1948bc
gh-143008: Fix Null pointer dereferences in TextIOWrapper underlying stream access (#145957)
TextIOWrapper keeps its underlying stream in a member called
`self->buffer`. That stream can be detached by user code, such as custom
`.flush` implementations resulting in `self->buffer` being set to NULL.
The implementation often checked at the start of functions if
`self->buffer` is in a good state, but did not always recheck after
other Python code was called which could modify `self->buffer`.

The cases which need to be re-checked are hard to spot so rather than
rely on reviewer effort create better safety by making all self->buffer
access go through helper functions.

Thank you yihong0618 for the test, NEWS and initial implementation in
gh-143041.

Co-authored-by: yihong0618 <zouzou0208@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-06-09 12:31:44 +02:00
Barry Warsaw
fccf67a354
gh-150633: Minor improvement of a newly added test (#151103)
Minor improvement of a newly added test.
2026-06-08 19:21:00 +00:00