Commit Graph

31775 Commits

Author SHA1 Message Date
Sam Gross 79fae3b0a1
[3.13] gh-117657: Fix itertools.count thread safety (GH-119268) (#120007)
Fix itertools.count in free-threading mode
(cherry picked from commit 87939bd579)

Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
2024-06-03 22:47:34 +00:00
Sam Gross ae705319fc
[3.13] gh-117657: Fix race involving immortalizing objects (GH-119927) (#120005)
The free-threaded build currently immortalizes objects that use deferred
reference counting (see gh-117783). This typically happens once the
first non-main thread is created, but the behavior can be suppressed for
tests, in subinterpreters, or during a compile() call.

This fixes a race condition involving the tracking of whether the
behavior is suppressed.

(cherry picked from commit 47fb4327b5)
2024-06-03 22:21:32 +00:00
Miss Islington (bot) 6b10467fbc
[3.13] gh-118835: pyrepl: Fix prompt length computation for custom prompts containing ANSI escape codes (GH-119942) (#119990)
gh-118835: pyrepl: Fix prompt length computation for custom prompts containing ANSI escape codes (GH-119942)
(cherry picked from commit 2e0aa731ae)

Co-authored-by: Daniel Hollas <daniel.hollas@bristol.ac.uk>
2024-06-03 17:31:26 +00:00
Miss Islington (bot) 060d846f43
[3.13] Use Cirrus M1 macOS runners for CI (GH-119979) (GH-119986)
(cherry picked from commit 6acb32fac3)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Ee Durbin <ee@python.org>
2024-06-03 18:15:37 +02:00
Victor Stinner ac35d9621b
[3.13] gh-111201: Skip pyrepl Windows tests earlier (#119848) (#119924)
gh-111201: Skip pyrepl Windows tests earlier (#119848)

Don't attempt to load pyrepl Windows console if platforms others than
Windows. For example, the import can fail if ctypes is missing.

(cherry picked from commit 91601a5596)
2024-06-01 21:21:13 +00:00
Miss Islington (bot) 225c3cd6c1
[3.13] GH-89727: Fix `shutil.rmtree()` recursion error on deep trees (GH-119808) (#119918)
Implement `shutil._rmtree_safe_fd()` using a list as a stack to avoid emitting recursion errors on deeply nested trees.

`shutil._rmtree_unsafe()` was fixed in a150679f90.

(cherry picked from commit 53b1981fb0)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2024-06-01 20:38:55 +01:00
Miss Islington (bot) 0ea77d49cc
[3.13] gh-113892: Add a extra check to `ProactorEventLoop.sock_connect` to ensure that the given socket is in non-blocking mode (GH-119519) (#119912)
(cherry picked from commit cf3bba3f06)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-06-01 16:27:54 +00:00
Jelle Zijlstra a0559849ac
[3.13] gh-119821: Support non-dict globals in LOAD_FROM_DICT_OR_GLOBALS (#119822) (#119889)
dSupport non-dict globals in LOAD_FROM_DICT_OR_GLOBALS

The implementation basically copies LOAD_GLOBAL. Possibly it could be deduplicated,
but that seems like it may get hairy since the two operations have different operands.

This is important to fix in 3.14 for PEP 649, but it's a bug in earlier versions too,
and we should backport to 3.13 and 3.12 if possible.

(cherry picked from commit 80a4e38994)
2024-05-31 21:56:26 -07:00
Miss Islington (bot) 0a266f7e74
[3.13] gh-74929: PEP 667 C API documentation (gh-119892)
* Add docs for new APIs
* Add soft-deprecation notices
* Add What's New porting entries
* Update comments referencing `PyFrame_LocalsToFast()` to mention the proxy instead
* Other related cleanups found when looking for refs to the deprecated APIs

(cherry picked from commit 3859e09e3d)

Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2024-06-01 04:23:04 +00:00
Miss Islington (bot) a5272e63ef
[3.13] gh-118894: Make asyncio REPL use pyrepl (GH-119433) (#119884)
(cherry picked from commit 2237946af0)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-31 17:15:44 -04:00
Miss Islington (bot) 8e0777df1f
gh-119690: Adds Unicode support for named pipes in _winapi (GH-119717)
(cherry picked from commit 78d697b7d5)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-05-31 16:22:30 +00:00
Miss Islington (bot) ea48de4f4f
[3.13] gh-119585: Fix crash involving `PyGILState_Release()` and `PyThreadState_Clear()` (GH-119753) (#119859)
Make sure that `gilstate_counter` is not zero in when calling
`PyThreadState_Clear()`. A destructor called from `PyThreadState_Clear()` may
call back into `PyGILState_Ensure()` and `PyGILState_Release()`. If
`gilstate_counter` is zero, it will try to create a new thread state before
the current active thread state is destroyed, leading to an assertion failure
or crash.
(cherry picked from commit bcc1be39cb)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-05-31 15:29:50 +00:00
Miss Islington (bot) d6faac6d1f
[3.13] gh-111201: Support pyrepl on Windows (GH-119559) (GH-119850)
(cherry picked from commit 0d07182821)

Co-authored-by: Dino Viehland <dinoviehland@gmail.com>
Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-31 17:18:28 +02:00
Miss Islington (bot) 38bf39cb4b
[3.13] gh-111201: Improve pyrepl auto indentation (GH-119606) (GH-119833)
- auto-indent when editing multi-line block
- ignore comments

(cherry picked from commit dae0375bd9)

Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
2024-05-31 11:51:53 +02:00
Miss Islington (bot) 978b86a91e
[3.13] gh-107262: Update Tkinter tests for Tcl/Tk 8.6.14 (GH-119322) (GH-119806)
(cherry picked from commit 9732ed5ca9)

Co-authored-by: James De Bias <81095953+DBJim@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-05-30 21:16:35 +00:00
Miss Islington (bot) d6bede815d
[3.13] gh-119791: Fix new Tkinter tests for wantobjects=0 (GH-119792) (GH-119794)
PhotoImage.get() retruns a string instead of a 3-tuple of integers
in this case.
(cherry picked from commit e875c2d752)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-05-30 19:16:57 +00:00
Miss Islington (bot) 083bf3ad17
[3.13] GH-89727: Fix FD leak on `os.fwalk()` generator finalization. (GH-119766) (#119767)
GH-89727: Fix FD leak on `os.fwalk()` generator finalization. (GH-119766)

Follow-up to 3c890b50. Ensure we `os.close()` open file descriptors when
the `os.fwalk()` generator is finalized.
(cherry picked from commit a5fef800d3)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2024-05-30 04:40:21 +00:00
Miss Islington (bot) 810a09ad37
[3.13] GH-89727: Fix `os.fwalk()` recursion error on deep trees (GH-119638) (#119764)
GH-89727: Fix `os.fwalk()` recursion error on deep trees (GH-119638)

Implement `os.fwalk()` using a list as a stack to avoid emitting recursion
errors on deeply nested trees.
(cherry picked from commit 3c890b503c)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2024-05-30 03:28:55 +00:00
Miss Islington (bot) 06c62d697a
[3.13] gh-119260: Clarify is_dataclass Behavior for Subclasses in Documentation and Tests (GH-119480) (#119760)
gh-119260: Clarify is_dataclass Behavior for Subclasses in Documentation and Tests (GH-119480)
(cherry picked from commit bf4ff3ad2e)

Co-authored-by: Aditya Borikar <adityaborikar2@gmail.com>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2024-05-30 01:28:31 +00:00
Eric Snow af57832e63
[3.13] gh-117398: Add multiphase support to _datetime (gh-119694)
This is an unrevert of d58ebf0 (gh-119636), which was reverted by 9216a53 (gh-119639) due to problems which have been resolved.

This is minimal support for multiphase init. Subinterpreters are not supported yet. That will be addressed in a later change.

(cherry picked from commit 3e8b609)

Co-authored-by: Erlend E. Aasland erlend@python.org
2024-05-29 15:54:47 -06:00
Miss Islington (bot) 061abf8e4c
[3.13] GH-89727: Partially fix `shutil.rmtree()` recursion error on deep trees (GH-119634) (#119748)
GH-89727: Partially fix `shutil.rmtree()` recursion error on deep trees (GH-119634)

Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.

(cherry picked from commit a150679f90)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-05-29 20:41:03 +00:00
Miss Islington (bot) c3cfc04a73
gh-119070: Fix py.exe handling of /usr/bin/env commands missing extension (GH-119426)
(cherry picked from commit df93f5d4bf)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-05-29 20:06:38 +00:00
Miss Islington (bot) 40a024c983
[3.13] gh-119555: catch SyntaxError from compile() in the InteractiveColoredConsole (GH-119557) (#119709) 2024-05-29 12:04:45 +01:00
Miss Islington (bot) 17d3398486
[3.13] gh-119443: Turn off from __future__ import annotations in REPL (GH-119493) (#119697)
gh-119443: Turn off from __future__ import annotations in REPL (GH-119493)
(cherry picked from commit a8e35e8eba)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-05-29 01:26:19 +00:00
Miss Islington (bot) c0e9961798
[3.13] gh-119011: `type.__type_params__` now return an empty tuple (GH-119296) (#119678)
(cherry picked from commit 6b240c2308)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-05-28 19:09:04 +00:00
Jelle Zijlstra 6394a72e99
[3.13] gh-119311: Fix name mangling with PEP 695 generic classes (#119464) (#119643)
Fixes #119311. Fixes #119395.

(cherry picked from commit a9a74da4a0)
2024-05-28 11:03:33 -07:00
Miss Islington (bot) 2b46253c5f
[3.13] gh-119581: Add a test of InitVar with name shadowing (GH-119582) (#119672)
gh-119581: Add a test of InitVar with name shadowing (GH-119582)
(cherry picked from commit 6ec371223d)

Co-authored-by: Steven Troxler <steven.troxler@gmail.com>
2024-05-28 17:41:02 +00:00
Miss Islington (bot) dcf585d0c1
[3.13] Re-order imports to align with zipp 3.18.2 (GH-119587) (#119589)
Re-order imports to align with zipp 3.18.2 (GH-119587)
(cherry picked from commit 5482a939ac)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-05-28 08:49:13 -04:00
Miss Islington (bot) 3b111a38ea
[3.13] gh-116860: Remove outdated `test_parserhack` from `test_future` (GH-116861) (#119649)
gh-116860: Remove outdated `test_parserhack` from `test_future` (GH-116861)
(cherry picked from commit 669175bf8e)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-05-28 09:55:37 +00:00
Eric Snow 9216a5336f
[3.13] gh-117398: Revert gh-119636, Add multiphase support to _datetime (#119639)
Revert "[3.13] gh-117398: Add multiphase support to _datetime (gh-119373) (gh-119636)"

This reverts commit d58ebf073c.
2024-05-28 00:52:52 +00:00
Miss Islington (bot) d58ebf073c
[3.13] gh-117398: Add multiphase support to _datetime (gh-119373) (gh-119636)
This is minimal support.  Subinterpreters are not supported yet.  That will be addressed in a later change.

(cherry picked from commit 3e8b60905e)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-05-27 16:36:32 -06:00
Miss Islington (bot) 660125f864
[3.13] gh-119584: Fix test_import Failed Assertion (gh-119623) (gh-119633)
The fix in gh-119561 introduced an assertion that doesn't hold true if any of the three new test extension modules are loaded more than once.  This is fine normally but breaks if the new test_check_state_first() is run more than once, which happens for refleak checking and with the regrtest --forever flag.  We fix that here by clearing each of the three modules after loading them.  We also tweak a check in _modules_by_index_check().

(cherry picked from commit ae7b17673f)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-05-27 20:04:13 +00:00
Miss Islington (bot) bd9983cab8
[3.13] gh-119560: Drop an Invalid Assert in PyState_FindModule() (gh-119561) (gh-119632)
The assertion was added in gh-118532 but was based on the invalid assumption that PyState_FindModule() would only be called with an already-initialized module def.  I've added a test to make sure we don't make that assumption again.

(cherry picked from commit 0c5ebe13e9)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-05-27 19:11:29 +00:00
Miss Islington (bot) cc38ee1edb
gh-118263: Add additional arguments to path_t (Argument Clinic type) in posixmodule (GH-118355)
(cherry picked from commit 96b392df30)

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
2024-05-24 18:26:06 +00:00
Miss Islington (bot) c864efba25
[3.13] gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (GH-119216) (#119497)
* gh-118692: Avoid creating unnecessary StopIteration instances for monitoring (GH-119216)
(cherry picked from commit 6e9863d7a3)

---------

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-05-24 10:18:13 +00:00
Victor Stinner c750061047
[3.13] gh-119461: Fix ThreadedVSOCKSocketStreamTest (#119465) (#119479)
gh-119461: Fix ThreadedVSOCKSocketStreamTest (#119465)

Fix ThreadedVSOCKSocketStreamTest: if get_cid() returns the host
address or the "any" address, use the local communication address
(loopback): VMADDR_CID_LOCAL.

On Linux 6.9, apparently, the /dev/vsock device is now available but
get_cid() returns VMADDR_CID_ANY (-1).

(cherry picked from commit e94dbe4ed8)
2024-05-23 22:27:04 +00:00
Miss Islington (bot) d98d6b1776
[3.13] gh-118727: Don't drop the GIL in `drop_gil()` unless the current thread holds it (GH-118745) (#119474)
`drop_gil()` assumes that its caller is attached, which means that the current
thread holds the GIL if and only if the GIL is enabled, and the enabled-state
of the GIL won't change. This isn't true, though, because `detach_thread()`
calls `_PyEval_ReleaseLock()` after detaching and
`_PyThreadState_DeleteCurrent()` calls it after removing the current thread
from consideration for stop-the-world requests (effectively detaching it).

Fix this by remembering whether or not a thread acquired the GIL when it last
attached, in `PyThreadState._status.holds_gil`, and check this in `drop_gil()`
instead of `gil->enabled`.

This fixes a crash in `test_multiprocessing_pool_circular_import()`, so I've
reenabled it.
(cherry picked from commit be1dfccdf2)

Co-authored-by: Brett Simmers <swtaarrs@users.noreply.github.com>
2024-05-23 21:27:38 +00:00
Miss Islington (bot) 8fd8cc564b
[3.13] gh-119469: Fix _pyrepl reference leaks (GH-119470) (#119471)
(cherry picked from commit 6e012ced6c)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-23 19:58:59 +02:00
Miss Islington (bot) 251ef2e36f
[3.13] GH-117195: Avoid assertion error in `object.__sizeof__` (GH-117220) (GH-119456) 2024-05-23 16:58:34 +01:00
Miss Islington (bot) 58dbb4a4b0
[3.13] gh-111201: Speed up paste mode in the REPL (#119341) (GH-119432) (#119439)
(cherry picked from commit e6572e8f98)

Also includes:

* gh-111201: Use calc_complete_screen after bracketed paste in PyREPL (GH-119432)
(cherry picked from commit 14b063cbf1)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
2024-05-23 04:23:40 +00:00
Lysandros Nikolaou 9fa1b4fc46
[3.13] gh-118911: Trailing whitespace in a block shouldn't prevent the user from terminating the code block (GH-119355) (#119404)
(cherry picked from commit 5091c4400c)

Co-authored-by: Aya Elsayed <ayah.ehab11@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-23 00:12:26 -04:00
Lysandros Nikolaou 9435124d4a
[3.13] gh-111201: auto-indentation in _pyrepl (GH-119348) (#119427)
(cherry picked from commit cd516cd1f5)

Co-authored-by: Arnon Yaari <wiggin15@yahoo.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-22 23:14:03 +02:00
Lysandros Nikolaou e6e4efcc86
[3.13] gh-119357: Increase test coverage for keymap in _pyrepl (GH-119358) (#119414)
(cherry picked from commit 73ab83b27f)

Co-authored-by: Eugene Triguba <eugenetriguba@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-22 23:13:01 +02:00
Miss Islington (bot) 08416065a7
[3.13] gh-119247: Add macros to use PySequence_Fast safely in free-threaded build (GH-119315) (#119419)
Add `Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST` and
`Py_END_CRITICAL_SECTION_SEQUENCE_FAST` macros and update `str.join` to use
them. Also add a regression test that would crash reliably without this
patch.
(cherry picked from commit baf347d916)

Co-authored-by: Josh {*()} Rosenberg <26495692+MojoVampire@users.noreply.github.com>
2024-05-22 19:24:02 +00:00
Miss Islington (bot) bfd9c3ea53
[3.13] gh-119213: Be More Careful About _PyArg_Parser.kwtuple Across Interpreters (gh-119331) (gh-119410)
_PyArg_Parser holds static global data generated for modules by Argument Clinic.  The _PyArg_Parser.kwtuple field is a tuple object, even though it's stored within a static global.  In some cases the tuple is statically allocated and thus it's okay that it gets shared by multiple interpreters.  However, in other cases the tuple is set lazily, allocated from the heap using the active interprepreter at the point the tuple is needed.

This is a problem once that interpreter is destroyed since _PyArg_Parser.kwtuple becomes at dangling pointer, leading to crashes.  It isn't a problem if the tuple is allocated under the main interpreter, since its lifetime is bound to the lifetime of the runtime.  The solution here is to temporarily switch to the main interpreter.  The alternative would be to always statically allocate the tuple.

This change also fixes a bug where only the most recent parser was added to the global linked list.

(cherry picked from commit 81865002ae)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-05-22 12:09:48 -06:00
Miss Islington (bot) a463cd8e45
[3.13] gh-118893: Evaluate all statements in the new REPL separately (GH-119318) (#119408)
(cherry picked from commit a3e4fec873)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-22 16:22:01 +00:00
Miss Islington (bot) eafd633fac
[3.13] gh-119205: Fix autocompletion bug in new repl (GH-119229) (#119407)
(cherry picked from commit 506b1a3ff6)

Co-authored-by: Koudai Aono <koxudaxi@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-22 16:07:38 +00:00
Lysandros Nikolaou ac9163637b
[3.13] gh-111201: Remove readline dependency from the PyREPL (GH-119262) (#119403)
(cherry picked from commit 561ff1fa71)
2024-05-22 11:45:11 -04:00
Lysandros Nikolaou 721459831a
[3.13] gh-119306: Break up _pyrepl tests (GH-119307) (#119362)
(cherry picked from commit f49df4f486)

Co-authored-by: Eugene Triguba <eugenetriguba@gmail.com>
2024-05-22 11:02:18 -04:00
Miss Islington (bot) 6892b400dc
[3.13] gh-118643: Fix AttributeError in the email module (GH-119099) (GH-119389)
Fix regression introduced in gh-100884: AttributeError when re-fold a long
address list.

Also fix more cases of incorrect encoding of the address separator in the
address list missed in gh-100884.
(cherry picked from commit 858b9e85fc)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-05-22 14:07:38 +03:00