126831 Commits

Author SHA1 Message Date
Adam Turner
4c56563f7a
GH-133336: Remove reserved `-J` flag for Jython (#133444) 2025-05-05 15:09:19 +00:00
Victor Stinner
c336f1c312
Revert "gh-124715: Fix method_dealloc(): use PyObject_GC_UnTrack() (#133199)" (#133434)
This reverts commit 662dd294563ce86980c640ad67e3d460a72c9cb9.

The root issue was fixed by the
commit f554237b8ef6c60df651ac17eb0ef0c095cef185.
2025-05-05 17:04:43 +02:00
Sergey Miryanov
99a0d7e5b3
gh-131878: Handle top level exceptions in new pyrepl and prevent of closing it (#131910)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2025-05-05 16:54:19 +02:00
Sergey B Kirpichev
1bc16504ef
gh-61103: drop unused Py_HAVE_C_COMPLEX define (GH-133435)
Py_HAVE_C_COMPLEX was added in 3.14 so the removal doesn't need a deprecation
period even under a strict reading of PEP 387.

The Py_FFI_SUPPORT_C_COMPLEX check configure check implies support for
complex types in ctypes.
2025-05-05 15:50:57 +02:00
Petr Viktorin
59f78d7b06
gh-131747: ctypes: Deprecate _pack_ implicitly setting _layout_ = 'ms' (GH-133205)
On non-Windows, warn when _pack_ implicitly changes default _layout_
to 'ms'.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-05-05 15:32:06 +02:00
Mark Shannon
f554237b8e
GH-133261: Make sure that the GC doesn't untrack objects in trashcan (GH-133431) 2025-05-05 13:44:50 +01:00
Victor Stinner
8d5f3cd2ce
gh-133419: fix test_external_inspection race assert (#133433)
Follow-up of commit c4cc5d58aee6a3be55a95efee6ec25d5774f7b5f,
fix more tests.
2025-05-05 12:38:51 +00:00
Lysandros Nikolaou
b97328ef5d
gh-107006: Move threading.local docstring to docs (#131840)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-05-05 15:00:15 +03:00
sobolevn
8467026ed6
Bump mypy to 1.15 (#133405) 2025-05-05 13:29:48 +03:00
Sergey B Kirpichev
8d0e07eb89
gh-61103: don't use C _Complex types to implement F/D/G in ctypes (GH-133237)
According to the C standard, the memory representation of _Complex types
is equivalent to 2-element arrays. Unlike _Complex, arrays are always available.

- drop _complex.h header
- use appropriate real arrays to replace complex types

Co-authored-by: Lisandro Dalcin <dalcinl@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-05-05 11:23:30 +02:00
Adam Turner
d530e74e44
GH-133410: Use commit hashes for change detection (gh-133416) 2025-05-05 10:49:12 +02:00
Tian Gao
ff4959b6b0
gh-113081: Highlight source code in pdb (#133355) 2025-05-05 09:49:52 +02:00
Thomas Grainger
08d7687094
gh-128307: Support eager_start=<bool> in create_eager_task_factory and various create_task functions (#128306)
Some create_task() functions were changed from `name=None, context=None` to `**kwargs`.

Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
2025-05-05 04:58:07 +00:00
Gregory P. Smith
c4cc5d58ae
[GH-133419] fix test_external_inspection race assert (#133422)
[tests] fix test_external_inspection race assert

either line could be where the inspection finds the foo()
function as after ready is sent, the process may not have made progress
onto the next line yet.  "solve" by putting the statements on the same
line.
2025-05-05 04:41:22 +00:00
Gregory P. Smith
b64aa302d7
[tests] test_subprocess maybe avoid a timeout race condition? (#133420)
The few buildbot failures on https://github.com/python/cpython/pull/133103
are possibly just due to racing a child process launch and exit?
2025-05-04 21:02:16 -07:00
mpage
78adb63ee1
gh-133371: Don't optimize LOAD_FAST instructions whose local is killed by DELETE_FAST (#133383)
In certain cases it's possible for locals loaded by `LOAD_FAST` instructions
to be on the stack when the local is killed by `DEL_FAST`. These `LOAD_FAST`
instructions should not be optimized into `LOAD_FAST_BORROW` as the strong
reference in the frame is killed while there is still a reference on the stack.
2025-05-04 21:00:11 -07:00
Nadeshiko Manju
2bbcaedb75
gh-133089: Use original timeout value for TimeoutExpired when the func subprocess.run is called with a timeout (GH-133103)
Signed-off-by: Manjusaka <me@manjusaka.me>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-05-05 01:15:31 +00:00
dura0ok
51d2459e4d
gh-133376: build: allow parser.c to be created if missing (#133378) 2025-05-05 02:34:31 +02:00
Adam Turner
3f80165a26
GH-91048: Minor fixes for `_remotedebugging & rename to _remote_debugging` (#133398) 2025-05-05 02:30:14 +02:00
Jelle Zijlstra
483d130e50
gh-131421: Fix ASDL tests (#133408)
PR #131419 broke this, but we failed to run tests on the PR due to a bug
in our script.
2025-05-04 23:46:21 +00:00
Samuel
30840706b0
gh-131421: fix ASDL grammar for Dict to have an expr?* keys field (#131419)
In the `ast` documentation for Python:

* https://docs.python.org/3/library/ast.html#ast.Dict
it is made clear that:

> When doing dictionary unpacking using dictionary literals the expression to be expanded goes in the values list, with a `None` at the corresponding position in `keys`.

Hence, `keys` is really a `expr?*` and *not* a `expr*`.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2025-05-04 16:03:38 -07:00
Jelle Zijlstra
af5799f305
gh-125618: Make FORWARDREF format succeed more often (#132818)
Fixes #125618.
2025-05-04 15:21:56 -07:00
Pablo Galindo Salgado
3109c47be8
gh-91048: Add filename and line number to external inspection routines (GH-133385)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2025-05-04 23:33:37 +02:00
Semyon Moroz
6ce60f1574
gh-131178: Add tests for ast command-line interface (#133329)
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-05-04 21:11:13 +00:00
Adam Turner
40be123499
Regenerate pcbuild.sln in Visual Studio 2022 (#133394)
* Regenerate pcbuild.sln in Visual Studio 2022
* Move _remotedebugging to the end
2025-05-04 21:10:19 +01:00
Bénédikt Tran
7b96701ccc
gh-133042: disable HACL* HMAC on Emscripten (#133064) 2025-05-04 21:55:49 +02:00
Matt Wozniski
d8c118f50d
gh-133351: Fix remote PDB's multi-line block tab completion (#133387) 2025-05-04 15:20:28 -04:00
Serhiy Storchaka
61b50a98b4
gh-109700: Improve stress tests for interpreter creation (GH-109946)
* Ensure that destructors are called in the test that created interpreters, not after finishing it.
* Try to create/run interpreters in threads simultaneously.
* Mark tests that requires over 6GB of memory with bigmemtest.
2025-05-04 21:53:24 +03:00
Serhiy Storchaka
95d2a81ba8
gh-81793: Skip tests for os.link() to symlink on Android (GH-133388) 2025-05-04 21:48:06 +03:00
Yan Yanchii
0a1fedb70b
gh-126835: Rename ast_opt.c to ast_preprocess.c and related stuff after moving const folding to the peephole optimizier (#131830) 2025-05-04 21:07:35 +03:00
Pablo Galindo Salgado
8eaaf16402
gh-91048: Relax test_async_global_awaited_by to fix flakyness (#133368)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
2025-05-04 16:52:20 +00:00
Ivan Kirpichnikov
a36367520e
gh-132457: make staticmethod and classmethod generic (#132460)
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-05-04 19:26:38 +03:00
Jelle Zijlstra
c8f233c53b
gh-132805: annotationlib: Fix handling of non-constant values in FORWARDREF (#132812)
Co-authored-by: David C Ellis <ducksual@gmail.com>
2025-05-04 08:49:13 -07:00
Jelle Zijlstra
7cb86c5def
gh-132426: Add get_annotate_from_class_namespace replacing get_annotate_function (#132490)
As noted on the issue, making get_annotate_function() support both types and
mappings is problematic because one object may be both. So let's add a new one
that works with any mapping.

This leaves get_annotate_function() not very useful, so remove it.
2025-05-04 07:26:42 -07:00
Serhiy Storchaka
5a57248b22
gh-81793: Always call linkat() from os.link(), if available (GH-132517)
This fixes os.link() on platforms (like Linux and OpenIndiana) where the
system link() function does not follow symlinks.

* On Linux, it now follows symlinks by default and if
  follow_symlinks=True is specified.
* On Windows, it now raises error if follow_symlinks=True is passed.
* On macOS, it now raises error if follow_symlinks=False is passed and
  the system linkat() function is not available at runtime.
* On other platforms, it now raises error if follow_symlinks is passed
  with a value that does not match the system link() function behavior
  if if the behavior is not known.

Co-authored-by: Joachim Henke <37883863+jo-he@users.noreply.github.com>
Co-authored-by: Thomas Kluyver <takowl@gmail.com>
2025-05-04 17:24:10 +03:00
Serhiy Storchaka
e9253ebf74
gh-122559: Synchronize C and Python implementation of the io module about pickling (GH-122628)
In the C implementation, remove __reduce__ and __reduce_ex__ methods
that always raise TypeError and restore __getstate__ methods that always
raise TypeErrori.

This restores fine details of the pre-3.12 behavior and unifies
both implementations.
2025-05-04 14:06:49 +00:00
Tomas R.
a247dd300e
gh-69605: Add PyREPL import autocomplete feature to 'What's New' (#133358) 2025-05-04 14:22:42 +03:00
Michael Forney
0af61fe2f4
bpo-44172: Keep reference to original window in curses subwindow objects (GH-26226)
The X/Open curses specification[0] and ncurses documentation[1]
both state that subwindows must be deleted before the main window.

Deleting the windows in the wrong order causes a double-free with
NetBSD's curses implementation.

To fix this, keep track of the original window object in the subwindow
object, and keep a reference to the original for the lifetime of
the subwindow.

[0] https://pubs.opengroup.org/onlinepubs/7908799/xcurses/delwin.html
[1] https://invisible-island.net/ncurses/man/curs_window.3x.html

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-04 13:29:44 +03:00
Mark Shannon
ac7d5ba96e
GH-133231: Changes to executor management to support proposed sys._jit module (GH-133287)
* Track the current executor, not the previous one, on the thread-state. 

* Batch executors for deallocation to avoid having to constantly incref executors; this is an ad-hoc form of deferred reference counting.
2025-05-04 10:05:35 +01:00
Matt Wozniski
1d9406e426
gh-133363: Fix Cmd completion for lines beginning with ! (#133364) 2025-05-03 22:50:37 -04:00
Emma Smith
3b4333583f
gh-132983: Introduce _zstd bindings module (GH-133027)
* Add _zstd module for https://peps.python.org/pep-0784/

This commit introduces the `_zstd` module, with bindings to libzstd from
the pyzstd project. It also includes the unix build system configuration.
Windows build system support will be integrated independently as it
depends on integration with cpython-source-deps.

* Add _zstd to modules

* Fix path for compression.zstd module

* Ignore _zstd module like _io

* Expand module state macros to improve code quality

Also removes module state references from the classes in the _zstd
module and instead uses PyType_GetModuleState()

* Remove backticks suggested in review

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>

* Use critical sections to lock object state

This should avoid races and deadlocks.

* Remove compress/decompress and mark module as not reliant on the GIL

The `compress`/`decompress` functions will be moved to Python code for simplicity.
C implementations can always be re-added in the future.

Also, mark _zstd as not requiring the GIL.

* Lift critical section to avoid clang warning

* Respond to comments by picnixz

* Call out pyzstd explicitly in license description

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>

* Use a much more robust implementation...

... for `get_zstd_state_from_type`

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Use PyList_GetItemRef for thread safety purposes

* Use a macro for the minimum supported version

* remove const from primivite types

* Use PyMem_New in another spot

* Simplify error handling in _get_frame_size

* Another simplification of error handling in get_frame_info

* Rename _module_state to mod_state

* Rewrite comment explaining the context of the code

* Add link to pyzstd

* Add TODO about refactoring dict training code

* Use PyModule_AddObjectRef over PyModule_AddObject

PyModule_AddObject is soft-deprecated, so we should use PyModule_AddObjectRef

* Check result of OutputBufferGrow

* Simplify return logic in `add_constant_to_type`

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Ignore return value of _zstd_clear()

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Remove redundant comments

* Remove __reduce__ from ZstdDict

We should instead document that to pickle a dictionary a user should use
the `.dict_content` attribute.

* Use PyUnicode_FromFormat instead of a buffer

* Don't use C constants/types in error messages

* Make error messages easier to understand for Python users

* Lower minimum required version 1.4.0

* Use casts and make slot function signatures correct

* Be consistent with CPython on const usage

* Make else clauses in line with PEP 7

* Fix over-indented blocks in argument clinic

* Add critical section around ZSTD_DCtx_setParameter

* Add a TODO about refactoring critical sections

* Use Py_UNREACHABLE

* Move bytes operations out of Py_BEGIN_ALLOW_THREADS

* Add TODO about ensuring a lock is held

* Remove asserts that may not be correct

* Add TODO to make ZstdDict and others GC objects

* Make objects GC tracked

* Remove unused include

* Fix some memory issues

* Fix refleaks on module and in ZstdDict

* Update configure to check for ZDICT_finalizeDictionary

* Properly check version in configure

* exit(1) if check fails

* Use AC_RUN_IFELSE

* Use a define() to re-use version check

* Actually properly set _zstd module status based on version

---------

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-05-04 01:29:55 +00:00
Pablo Galindo Salgado
2bc8365231
GH-91048: Add utils for printing the call stack for asyncio tasks (#133284) 2025-05-04 00:51:57 +00:00
Serhiy Storchaka
7363e8d24d
gh-133139: Add curses.assume_default_colors() (GH-133145)
This is a refinement of the curses.use_default_colors() function which
allows to change the color pair 0.
2025-05-03 23:33:22 +03:00
sobolevn
3e256b9118
gh-123539: Add new error message changes to "Whats New" (#133344) 2025-05-03 19:18:40 +02:00
sobolevn
881144fa58
gh-133210: Fix test_rlcompleter in --without-doc-strings mode (#133332) 2025-05-03 18:38:27 +03:00
Hugo van Kemenade
a85f526742
gh-123299: Add PyREPL syntax highlighting to release highlights (#133321) 2025-05-03 17:25:13 +02:00
Sergey B Kirpichev
f16f06f336
gh-133304: workaround for RISC-V in PyFloat_Pack4/Unpack4() (#133328) 2025-05-03 17:07:52 +02:00
Serhiy Storchaka
84a08f8629
gh-133306: Use \z instead of \Z in regular expressions in the stdlib (GH-133337) 2025-05-03 17:58:49 +03:00
Serhiy Storchaka
add0ca9ea0
gh-133306: Use \z instead of \Z in fnmatch.translate() and glob.translate() (GH-133338) 2025-05-03 17:58:21 +03:00
sobolevn
cb3174113e
gh-133117: Enable stricter mypy checks for tomllib (#133206) 2025-05-03 16:57:09 +03:00