126671 Commits

Author SHA1 Message Date
Donghee Na
75cbb8d89e
gh-132070: Use _PyObject_IsUniquelyReferenced in unicodeobject (gh-133039)
---------

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-04-29 09:48:53 +09:00
Eric Snow
bdd23c0bb9
gh-132775: Add _PyMarshal_GetXIData() (gh-133108)
Note that the bulk of this change is tests.
2025-04-28 17:23:46 -06:00
Neil Schemenauer
68a737691b
gh-125142: add REPL help text for keyboard shortcuts (gh-125143) 2025-04-28 14:17:34 -07:00
Neil Schemenauer
31a500a92b
Add internal docs about the free-threaded GC. (gh-132562) 2025-04-28 13:32:39 -07:00
Neil Schemenauer
e414a2d81c
gh-127266: avoid data races when updating type slots (gh-131174)
In the free-threaded build, avoid data races caused by updating type slots
or type flags after the type was initially created.  For those (typically
rare) cases, use the stop-the-world mechanism.  Remove the use of atomics
when reading or writing type flags.  The use of atomics is not sufficient to
avoid races (since flags are sometimes read without a lock and without
atomics) and are no longer required.
2025-04-28 20:28:44 +00:00
Neil Schemenauer
22f0730d40
gh-122320: Limit dict key versions used by test_opcache. (gh-132961)
The `test_load_global_module()` test consumes a lot of dict key versions.
Skip the test if we have consumed half of the available versions that can be
used for the "load global" cache.
2025-04-28 12:54:55 -07:00
Barney Gale
336322b341
GH-128520: pathlib ABCs tests: use explicit text encoding (#133105)
Follow-up to fbffd70. Set `encoding='utf-8'` when reading and writing text
in the tests for the private pathlib ABCs, which allows the tests to run
with `-W error -X warn_default_encoding`
2025-04-28 20:18:56 +01:00
Eric Snow
606003ffa9
gh-132775: Add _PyBytes_GetXIData() (gh-133101)
This is the base for several other XIData wrappers, like pickle and marshal. It is essentially a refactor of the existing bytes XIData code.
2025-04-28 12:52:36 -06:00
Neil Schemenauer
31d1342de9
gh-132942: Fix races in type lookup cache (gh-133032)
Two races related to the type lookup cache, when used in the
free-threaded build.  This caused test_opcache to sometimes fail (as
well as other hard to re-produce failures).
2025-04-28 11:52:08 -07:00
Eric Snow
fe462f5a91
gh-132775: Drop PyUnstable_InterpreterState_GetMainModule() (gh-132978)
We replace it with _Py_GetMainModule(), and add _Py_CheckMainModule(), but both in the internal-only C-API.  We also add _PyImport_GetModulesRef(), which is the equivalent of _PyImport_GetModules(), but which increfs before the lock is released.

This is used by a later change related to pickle and handling __main__.
2025-04-28 12:46:22 -06:00
Eric Snow
c17238251f
gh-132775: Add _PyModule_GetFilenameObject() and _PyModule_GetFilenameUTF8() (gh-132979)
They are derived from the existing `PyModule_GetFilenameObject().

They are used by a later change related to pickle and handling __main__.
2025-04-28 12:41:32 -06:00
Serhiy Storchaka
25186c2472
gh-132742: Fix newly added tcflush() tests on Android (GH-133070) 2025-04-28 21:41:09 +03:00
Steve Dower
3940e1f873
gh-132930: Improve the names of IDLE and PyDoc shortcuts (GH-133091) 2025-04-28 19:09:20 +01:00
Barney Gale
fbffd70328
GH-128520: pathlib ABCs: raise text encoding warnings at correct stack level (#133051)
Ensure that warnings about unspecified text encodings are emitted from
`ReadablePath.read_text()`, `WritablePath.write_text()` and `magic_open()`
with the correct stack level set.
2025-04-28 19:04:20 +01:00
Eric Snow
6f04325992
gh-132775: Cleanup Related to crossinterp.c Before Further Changes (gh-132974)
This change consists of adding tests and moving code around, with some renaming thrown in.
2025-04-28 11:55:15 -06:00
sobolevn
b739ec5ab7
gh-133054: Skip test_pyrepl tests when cannot use pyrepl is reported (#133055)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-04-28 19:09:28 +03:00
Jelle Zijlstra
58567cc18c
gh-132952: Speed up startup by importing _io instead of io (#132957) 2025-04-28 08:38:56 -07:00
Jelle Zijlstra
7f16f1bc11
typing, annotationlib: clean tests (#133087)
- Add @cpython_only decorator to lazy import tests
- Rename reference to SOURCE format
- Always two newlines between test case classes
- Merge two classes of ForwardRef tests
- Use get_annotations instead of annotationlib.get_annotations
- Format test_annotationlib with Black (not expecting that we'll keep this up
  but it's close to Black-formatted right now)
2025-04-28 08:38:11 -07:00
Hugo van Kemenade
4cec0b510b
gh-129965: Add more missing MIME types (#132845) 2025-04-28 15:30:35 +00:00
Serhiy Storchaka
c2eaeee3dc
gh-132915: Try to detect a buffer overflow in fcntl() and ioctl() (GH-132919)
SystemError is raised when buffer overflow is detected.
The stack and memory can already be corrupted, so treat this error as fatal.
2025-04-28 17:56:10 +03:00
Semyon Moroz
0f84f6b334
gh-132726: Change the heading of sysconfig CLI section (#133035) 2025-04-28 17:44:49 +03:00
Hugo van Kemenade
ee9102a535
gh-75223: Deprecate undotted extensions in mimetypes.MimeTypes.add_type (#128638)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Daniel Watkins <daniel@daniel-watkins.co.uk>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2025-04-28 14:23:57 +00:00
Victor Stinner
fe8ad53443
gh-132983: Convert compression._common to a package (#133086)
Add an "__init__.py" file. Fix test_tools.test_freeze.
2025-04-28 14:13:06 +00:00
Bénédikt Tran
a99bfaa53c
gh-133073: avoid NULL + 0 arithmetic in list_extend_* functions (#133074) 2025-04-28 15:59:09 +02:00
Petr Viktorin
4ebbfcf30e
gh-87135: Raise PythonFinalizationError when joining a blocked daemon thread (gh-130402)
If `Py_IsFinalizing()` is true, non-daemon threads (other than the current one)
are done, and daemon threads are prevented from running, so they
cannot finalize themselves and become done. Joining them (without timeout)
would block forever.

Raise PythonFinalizationError instead of hanging.

Raise even when a timeout is given, for consistency with trying to join your own thread.

See gh-123940 for a use case: calling `join()` from `__del__`. This is
ill-advised, but an exception should at least make it easier to diagnose.
2025-04-28 15:48:48 +02:00
Wulian233
995b1a72f2
Fixed a typo in the PCbuild/readme.txt about PGO clang-cl (#133083)
Fixed a typo in the readme.txt section about PGO clang-cl
2025-04-28 13:39:16 +00:00
Sergey B Kirpichev
6157135a8d
gh-130317: Fix PyFloat_Pack/Unpack[24] for NaN's with payload (#130452)
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-04-28 15:23:26 +02:00
Jelle Zijlstra
922049b613
gh-130907: Treat all module-level annotations as conditional (#131550) 2025-04-28 06:10:28 -07:00
Sergey B Kirpichev
5bf0f3666e
gh-53032: support IEEE 754 contexts in the decimal module (#122003)
This was in C version from beginning, but available only
on conditional compilation (EXTRA_FUNCTIONALITY).  Current
patch adds function to create IEEE contexts to the
pure-python module as well.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-04-28 15:05:56 +02:00
Steve Dower
e20ca6d1b0
gh-132930: Implement PEP 773 (GH-132931)
This change to the core CPython repo:
* Adds PyManager support to PC/layout
* Adds a warning message to the legacy py.exe if subcommands are invoked
* Add deprecation message to traditional installer
* Updates using/windows docs
2025-04-28 13:57:47 +01:00
Chris Eibl
11f457cf41
GH-114911: use time.perf_counter in Stopwatch (GH-131469)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-04-28 13:55:08 +02:00
Bénédikt Tran
e577439803
gh-131423: update note in Tools/ssl/make_ssl_data.py (#133077) 2025-04-28 11:11:46 +00:00
Bénédikt Tran
96bc1721d2
gh-111178: fix incorrect function signatures for Windows builds (#133072) 2025-04-28 13:05:39 +02:00
Yuki Kobayashi
4e04511cb9
gh-133033: Add docs for TypeIgnore (#133034)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-04-28 13:49:07 +03:00
Bénédikt Tran
af3f6fcb7e
gh-127604: ensure -ldl is passed only once to the linker (#133071) 2025-04-28 11:55:02 +02:00
Serhiy Storchaka
6677c2c165
gh-132987: Support __index__() for unsigned integers in Argument Clinic (GH-133011) 2025-04-28 11:02:18 +03:00
Serhiy Storchaka
ed8e886f4f
gh-132742: Improve tests for fcntl.ioctl() (GH-132791)
* Use better tests for integer argument.
* Add also parallel tests for tcflush() and tcflow().
2025-04-28 10:42:40 +03:00
Emma Smith
632978f005
gh-132983: Install compression package contents (#133063)
Include compression package contents as part of installs.
2025-04-28 14:44:20 +08:00
Bénédikt Tran
1b7470f8cb
gh-133061: do not mention UINT32_MAX in HMAC user-facing messages (#133062) 2025-04-28 01:14:12 +02:00
Yongzi Li
cd76eff26e
Docs: fix a couple typos in Doc/ (GH-132927)
fix minor typos
2025-04-27 15:56:58 -07:00
Bénédikt Tran
24436629ef
gh-127604: ensure -ldl is passed to the linker when dladdr1 is found (#133040) 2025-04-28 00:28:42 +02:00
Bénédikt Tran
3695ba93d5
gh-132993: expose HASHLIB_GIL_MINSIZE to private extension modules (#132999) 2025-04-27 22:20:15 +00:00
Michał Górny
019ee49d50
gh-133005: Support tarfile.open(mode="w|xz", preset=...) (GH-133007)
* gh-133005: Support `tarfile.open(mode="w|xz", preset=...)`

Support passing the `preset` option to `tarfile.open` when the file
is open with `mode="w|xz"`.  This aligns the behavior with `"w:xz"`
mode.

* Also raise an error for `compresslevel` or `preset` with wrong mode

Raise an error if `compresslevel` or `preset` argument is specified
for stream mode with incorrect compression. This should reduce the risk
of mistakes and align the stream modes with regular modes, that raise
an implicit TypeError on unsupported arguments.

* Apply suggestions from code review

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
2025-04-27 22:19:59 +00:00
Lukas
146b981f76
Silence system utils tests in emscripten python.sh (#133044)
Ensure that checks for system functions don't leak onto stdout on failure.
2025-04-28 06:13:02 +08:00
Valters Jansons
6985e2e6de
gh-132026: Ensure _MIPS_SIM has defined _ABI identifiers for comparison (GH-132027)
When built on a MIPS architecture, `_MIPS_SIM` is used to determine
architecture specifics. The value is expected to match either
`_ABIO32`, `_ABIN32` or `_ABI64`.

In `gcc` config/mips/mips.h these values are defined as compiler
`builtin_define` inside of a switch/case. That means, mips64el and
mips64 architectures know about `_ABI64` but don't know about `_ABIO32`
and `_ABIN32`. In turn, when CPython tries to use them in comparison,
they may be undefined identifiers.

In default compiler behavior, the undefined identifier will be
evaluated as zero, and it will not match `_MIPS_SIM`. However, the
issues pop up when `-Wundef` (or, even worse, `-Werror=undef`) compiler
flag is enabled. Then suddenly it's visible as a warning or error.
2025-04-27 21:56:00 +00:00
Emma Smith
20be6ba61a
gh-132983: Introduce compression package and move _compression module (GH-133018)
* Introduces `compression` package for https://peps.python.org/pep-0784/

This commit introduces the `compression` package, specified in PEP 784
to re-export the `lzma`, `bz2`, `gzip`, and `zlib` modules. Introduction
of `compression.zstd` will be completed in a future commit once the
`_zstd` module is merged.

This commit also moves the `_compression` private module to
`compression._common._streams`.

* Re-exports existing module docstrings.
2025-04-27 14:41:30 -07:00
Hunter Hogan
6d53b75283
gh-133046: Reformat the `ast` module docstring (GH-133050)
* Fix formatting in module docstring for `ast` https://github.com/python/cpython/issues/133046
* #133046 ast docstring: remove header, dedent, 80-char width.
* Keep existing wrapping

---------

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2025-04-27 14:35:56 -07:00
Mariusz Felisiak
28a2fd031e
gh-115032: Deprecate support for custom logging handlers with 'strm' argument. (GH-115314) 2025-04-27 22:18:14 +01:00
Gregory P. Smith
355ee1a429
[tests] fix test_fcntl issue when run in a ChromeOS linux runtime (GH-133053)
* [tests] test_fcntl fails when run in a ChromeOS linux runtime container.

It doesn't appear to support F_NOTIFY? Detect the lack of that and skip the test.
2025-04-27 13:28:23 -07:00
Sergey B Kirpichev
276252565c
gh-127495: Append to history file after every statement in PyREPL (GH-132294) 2025-04-27 15:32:37 +02:00