125179 Commits

Author SHA1 Message Date
Sam Gross
a10f99375e
Revert "GH-128914: Remove conditional stack effects from bytecodes.c and the code generators (GH-128918)" (GH-129202)
The commit introduced a ~2.5-3% regression in the free threading build.

This reverts commit ab61d3f4303d14a413bc9ae6557c730ffdf7579e.
2025-01-23 09:26:25 +00:00
Sergey B Kirpichev
d7d066c3ab
gh-127936, PEP 757: Convert marshal module to use import/export API for ints (#128530)
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-01-23 02:54:23 +00:00
Victor Stinner
1d485db953
gh-128863: Deprecate _PyLong_Sign() function (#129176)
Replace _PyLong_Sign() with PyLong_GetSign().
2025-01-23 03:11:53 +01:00
Victor Stinner
0093a31273
gh-119182: Use public PyUnicodeWriter in Python-ast.c (#129209)
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.

Use PyUnicodeWriter_WriteRepr() in ast_repr_list().
2025-01-23 00:57:37 +00:00
Victor Stinner
8eb9e76b5b
gh-119182: Use public PyUnicodeWriter in ast_unparse.c (#129208)
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.

* Add append_char() function.
* Add APPEND_CHAR() and APPEND_CHAR_FINISH() macros.
* Replace APPEND_STR() and APPEND_STR_FINISH() of single character
  with APPEND_CHAR() and APPEND_CHAR_FINISH().
2025-01-23 01:44:43 +01:00
Victor Stinner
327a257e6a
gh-119182: Use public PyUnicodeWriter in wrap_strftime() (#129206)
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.
2025-01-23 01:18:26 +01:00
Victor Stinner
719c9dd72f
gh-119182: Use public PyUnicodeWriter in time_strftime() (#129207)
Replace the private _PyUnicodeWriter API with the public
PyUnicodeWriter API.
2025-01-23 01:18:03 +01:00
Hood Chatham
960936fe90
gh-128627: Emscripten: Fix address calculation for wasm-gc trampoline (#128782)
Modifies the memory calculation to divide the entire memory address by 4, not just the base address.
2025-01-23 08:02:04 +08:00
Hugo van Kemenade
298dda5770
Add colour to GitHub Actions output (#129196) 2025-01-22 21:22:21 +00:00
Kirill Podoprigora
fc6d4b71eb
gh-129192: Use EnvironmentVarGuard to restore environment variables (#129193)
Co-authored-by: Cody Maloney <cmaloney@theoreticalchaos.com>
2025-01-22 20:39:26 +00:00
Łukasz Langa
67d804b494
GH-91048: Don't attempt to run on FreeBSD (#129189) 2025-01-22 19:27:58 +01:00
Yury Selivanov
188598851d
GH-91048: Add utils for capturing async call stack for asyncio programs and enable profiling (#124640)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
Co-authored-by: Jacob Coffee <jacob@z7x.org>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2025-01-22 17:25:29 +01:00
Pablo Galindo Salgado
60a3a0dd6f
gh-124363: Treat debug expressions in f-string as raw strings (#128399)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-01-22 16:24:54 +00:00
Tomas R.
ba9a4b6215
gh-128636: Fix crash in PyREPL when os.environ is overwritten with an invalid value (#128653) 2025-01-22 16:15:23 +00:00
Łukasz Langa
2ed5ee9a50
gh-129158: Fix unwanted trailing whitespace in test_asyncio.test_subprocess (#129181) 2025-01-22 13:52:45 +00:00
Mikhail Efimov
8e20e42cc6
gh-125723: Fix crash with f_locals when generator frame outlive their generator (#126956)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2025-01-22 15:50:01 +03:00
Thomas Grainger
24c84d816f
gh-128770: fix ResourceWarning in test_pyrepl (#128906) 2025-01-22 12:48:33 +00:00
sobolevn
a16ded10ad
gh-128894: Fix TracebackException._format_syntax_error on custom SyntaxError metadata (#128946) 2025-01-22 12:47:03 +00:00
Pablo Galindo Salgado
a9f5edbf5f
gh-129158: Ensure we restore unix_events.can_use_pidfd after SubprocessThreadedWatcherTests finishes (#129160) 2025-01-22 12:25:42 +00:00
Victor Stinner
9012fa741d
gh-128863: Deprecate private C API functions (#128864)
Deprecate private C API functions:

* _PyBytes_Join()
* _PyDict_GetItemStringWithError()
* _PyDict_Pop()
* _PyThreadState_UncheckedGet()
* _PyUnicode_AsString()
* _Py_HashPointer()
* _Py_fopen_obj()

Replace _Py_HashPointer() with Py_HashPointer().

Remove references to deprecated functions.
2025-01-22 11:04:19 +00:00
Mark Shannon
470a0a68eb
GH-128682: Change a couple of functions to only steal references on success. (GH-129132)
Change PyTuple_FromStackRefSteal and PyList_FromStackRefSteal to only steal on success to avoid escaping
2025-01-22 10:51:37 +00:00
Petr Viktorin
a65f802692
gh-61103: Add What's New entry for complex types in ctypes (GH-129129)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2025-01-22 10:59:20 +01:00
Joshua Root
edf803345a
gh-128902: Fix check for fallthrough attribute support (#128903)
Clang versions prior to 10 (which corresponds to Apple Clang 12) do not
support the GCC extension syntax __attribute__((fallthrough)), but do
evaluate __has_attribute(fallthrough) to 1 because they support the
C++11 style syntax [[fallthrough]]. The only way to tell if the GCC
style syntax is supported is thus to check the clang version.

Ref: 1e0affb6e5
2025-01-22 04:25:30 -05:00
Ken Jin
86c1a60d5a
gh-128563: Move GO_TO_INSTRUCTION and PREDICT to cases generator (GH-129115) 2025-01-22 09:22:25 +08:00
Tomas R.
767cf70844
gh-129093: Fix f-string debug text sometimes getting cut off when expression contains ! (#129159) 2025-01-22 00:26:37 +00:00
Adam Turner
01bcf13a1c
GH-121970: Extract `pydoc_topics` into a new extension (#129116) 2025-01-21 23:28:32 +00:00
Daniel Hollas
29caec62ee
gh-118878: Pyrepl: show completions menu below the current line (#118939)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2025-01-21 21:06:13 +00:00
Lysandros Nikolaou
5a9afe2362
gh-123024: Correctly prepare/restore around help and show-history commands (#124485)
Co-authored-by: Emily Morehouse <emily@cuttlesoft.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2025-01-21 21:04:30 +00:00
Pieter Eendebak
d147e5e52c
gh-126332: Fix pyrepl crash for double ctrl-z in line overflow (#126650)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2025-01-21 20:14:10 +00:00
Michael Kashirin
f18b226492
gh-126172: Fix a misleading statement in PYTHON_BASIC_REPL documentation (#127203)
Fix a misleading statement in PYTHON_BASIC_REPL documentation.
2025-01-21 20:05:19 +00:00
Sergey B Kirpichev
6105846390
gh-122845: fix parameter_list_starargs in function definition pseudo-grammar (#122847)
Thanks to Artur Chakhvadze for bugfix.
2025-01-21 20:04:07 +00:00
Tomas R.
7ad793e5db
gh-125553: Fix backslash continuation in untokenize (#126010) 2025-01-21 19:58:44 +00:00
Wim Jeantine-Glenn
a4760ef8e5
gh-128720: Fix doc inacurracy about __main__.__file__ existence in the REPL (#128721)
Fix doc inacurracy about __main__.__file__ existence in the REPL
2025-01-21 19:52:21 +00:00
Barney Gale
01d91500ca
GH-128520: Make pathlib._abc.WritablePath a sibling of ReadablePath (#129014)
In the private pathlib ABCs, support write-only virtual filesystems by
making `WritablePath` inherit directly from `JoinablePath`, rather than
subclassing `ReadablePath`.

There are two complications:

- `ReadablePath.open()` applies to both reading and writing
- `ReadablePath.copy` is secretly an object that supports the *read* side
  of copying, whereas `WritablePath.copy` is a different kind of object
  supporting the *write* side

We untangle these as follow:

- A new `pathlib._abc.magic_open()` function replaces the `open()` method,
  which is dropped from the ABCs but remains in `pathlib.Path`. The
  function works like `io.open()`, but additionally accepts objects with
  `__open_rb__()` or `__open_wb__()` methods as appropriate for the mode.
  These new dunders are made abstract methods of `ReadablePath` and
  `WritablePath` respectively.  If the pathlib ABCs are made public, we
  could consider blessing an "openable" protocol and supporting it in
  `io.open()`, removing the need for `pathlib._abc.magic_open()`.
- `ReadablePath.copy` becomes a true method, whereas `WritablePath.copy` is
  deleted. A new `ReadablePath._copy_reader` property provides a
  `CopyReader` object, and similarly `WritablePath._copy_writer` is a
  `CopyWriter` object. Once GH-125413 is resolved, we'll be able to move
  the `CopyReader` functionality into `ReadablePath.info` and eliminate
  `ReadablePath._copy_reader`.
2025-01-21 18:35:37 +00:00
Michael Droettboom
3d7c0e5366
gh-129141: Fix build on gcc-9.4.0 (GH-129142) 2025-01-21 19:13:33 +01:00
Hugo van Kemenade
05d12eecbd
gh-127873: Only check sys.flags.ignore_environment for PYTHON* env vars (#127877) 2025-01-21 16:10:08 +00:00
Petr Viktorin
13475e0a5a
gh-128889: Zero out memory ctypes for generated struct layout tests (GH-128944) 2025-01-21 16:29:02 +01:00
Serhiy Storchaka
4b37a6bda2
gh-71339: Fix an order-dependent failure in test_unittest (GH-129133)
It failed if it was preceded by test_builtin.
2025-01-21 16:45:20 +02:00
Ken Jin
5809b25909
gh-128563: Move lltrace into the frame struct (GH-129113) 2025-01-21 22:17:15 +08:00
Victor Stinner
31f149d5b3
gh-128679: Use _PyThreadState_GET() in tracemalloc.c (#129126)
Replace uncommon PyGILState_GetThisThreadState() with common
_PyThreadState_GET().
2025-01-21 14:43:31 +01:00
Bénédikt Tran
6a0f915aae
gh-129064: Fix RST markup for the NEWS and What's New entries (#129131)
This amends the NEWS and What's New entries introduced in 0a6412f9cc9e694e76299cfbd73ec969b7d47af6.
2025-01-21 12:43:09 +01:00
Victor Stinner
01de4af3e1
gh-126925: Make PyConfig.use_system_logger read-only (#129124)
The variable is only used once during early Python initialization, it
doesn't make sense to modify it at runtime.
2025-01-21 12:02:38 +01:00
Victor Stinner
80189ff647
Remove PyInit__imp() function (#129125)
This function was exposed by mistake to the public C API. It's the
only "PyInit" function which is exposed.
2025-01-21 11:58:43 +01:00
Bénédikt Tran
fafc618e2f
gh-111178: fix UBSan failures in Modules/_ctypes (#129071)
This fixes UBSan failures for the following objects:

- `DictRemoverObject` and `StructParamObject`,
- `CDataObject` and `CFieldObject`, and
- `PyCFuncPtrObject` and `PyCArgObject`.

On the default build, we convert the `LOCK_PTR` and `UNLOCK_PTR` macros to
functions with an unused parameter to ease "unused variable" compiler warnings
suppression. Finally, we also remove some redundant casts to `PyObject *`.
2025-01-21 11:50:13 +01:00
Bénédikt Tran
36f341ca3e
gh-127787: allow retrieving the clipped slice length in _PyUnicodeError_GetParams (GH-128980) 2025-01-21 11:45:53 +01:00
Petr Viktorin
bf150f61ad
gh-126349: test_turtle: Add cleanup to avoid reference leaks (GH-129079) 2025-01-21 11:28:34 +01:00
Mark Shannon
f5b6356a11
GH-128563: Add new frame owner type for interpreter entry frames (GH-129078)
Add new frame owner type for interpreter entry frames
2025-01-21 10:15:02 +00:00
Petr Viktorin
d3b1bb228c
gh-128156: Guard use of ffi_type_complex_double on macOS system libffi (GH-128680)
* Determine ffi complex support at runtime
* Also, generate SIMPLE_TYPE_CHARS once at runtime
2025-01-21 10:59:18 +01:00
Mark Shannon
7239da7559
GH-127953: Make line number lookup O(1) regardless of the size of the code object (GH-128350) 2025-01-21 09:33:23 +00:00
Serhiy Storchaka
f7cc7d296c
gh-71339: Use new assertion methods in test_import and test_importlib (GH-129052) 2025-01-21 11:24:19 +02:00