Commit Graph

122316 Commits

Author SHA1 Message Date
Miss Islington (bot) e5fb3a2385
[3.13] gh-117398: Use Per-Interpreter State for the _datetime Static Types (gh-120009)
We make use of the same mechanism that we use for the static builtin types.  This required a few tweaks.

This change is the final piece needed to make _datetime support multiple interpreters.  I've updated the module slot accordingly.

(cherry picked from commit 105f22ea46, AKA gh-119929)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-06-03 23:37:28 +00:00
Miss Islington (bot) c348e27cc1
[3.13] gh-117142: Support Importing ctypes in Isolated Interpreters (gh-120008)
This makes the support official.

(cherry picked from commit dba7a167db, AKA gh-119991)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-06-03 23:06:56 +00:00
Miss Islington (bot) 39510dadde
[3.13] gh-117398: Add datetime Module State (gh-120004)
I was able to make use of the existing datetime_state struct, but there was one tricky thing I had to sort out.  We mostly aren't converting to heap types, so we can't use things like PyType_GetModuleByDef() to look up the module state.  The solution I came up with is somewhat novel, but I consider it straightforward.  Also, it shouldn't have much impact on performance.

In summary, this main changes here are:

* I've added some macros to help hide how various objects relate to module state
* as a solution to the module state lookup problem, I've stored the last loaded module on the current interpreter's internal dict (actually a weakref)
* if the static type method is used after the module has been deleted, it is reloaded
* to avoid extra work when loading the module, we directly copy the objects (new refs only) from the old module state into the new state if the old module hasn't been deleted yet
* during module init we set various objects on the static types' __dict__s; to simplify things, we only do that the first time; once those static types have a separate __dict__ per interpreter, we'll do it every time
* we now clear the module state when the module is destroyed (before, we were leaking everything in _datetime_global_state)

(cherry picked from commit d82a7ba041, AKA gh-119810)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-06-03 17:05:04 -06:00
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) ca37034baa
[3.13] gh-117657: Avoid `sem_clockwait` in TSAN (GH-119915) (#119992)
The `sem_clockwait` function is not currently instrumented, which leads
to false positives.
(cherry picked from commit 41c1cefbae)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-06-03 18:07:22 +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
Miss Islington (bot) 671b740f45
gh-119679: Ensures correct import libraries are included in Windows install packages (GH-119790)
(cherry picked from commit fd01271366)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-06-03 15:06:53 +00:00
Miss Islington (bot) b26b410ce9
gh-102511: Amend 3.13.0b1.rst (GH-119895)
(cherry picked from commit 4765e1fa29)

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
2024-06-03 13:46:40 +00:00
Miss Islington (bot) 6db1eb98a4
[3.13] gh-119968: Improved monitoring c-api docs (GH-119969) (#119971)
gh-119968: Improved monitoring c-api docs (GH-119969)
(cherry picked from commit cae4c80714)

Co-authored-by: Awbert <119314310+SweetyAngel@users.noreply.github.com>
2024-06-03 09:49:14 +00:00
Miss Islington (bot) cc663b7e25
[3.13] gh-119336: Restore removed _PyLong_NumBits() function (GH-119418) (#119970)
gh-119336: Restore removed _PyLong_NumBits() function (GH-119418)

It is used by the pywin32 project.
(cherry picked from commit e50fac96e8)

Co-authored-by: Ethan Smith <ethan@ethanhs.me>
2024-06-03 09:29:07 +00:00
Miss Islington (bot) c3fc3a2db8
[3.13] gh-119856: Support exiting help() with just "exit" (GH-119858) (#119967)
gh-119856: Support exiting help() with just "exit" (GH-119858)
(cherry picked from commit 4223f1d828)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-06-03 09:10:39 +00:00
Miss Islington (bot) e5dfcea3e3
[3.13] gh-117657: Fix data races report by TSAN unicode-hash (gh-119907) (gh-119963)
gh-117657: Fix data races report by TSAN unicode-hash (gh-119907)
(cherry picked from commit 0594a27e5f)

Co-authored-by: Donghee Na <donghee.na@python.org>
2024-06-03 03:45:44 +00:00
Miss Islington (bot) 3709e1bbad
[3.13] gh-109975: What's New in Python 3.13: fix broken link for `telnetlib` alternative (GH-119958) (#119959)
(cherry picked from commit 117a8acdab)

Co-authored-by: Solomon Himelbloom <7608183+TechSolomon@users.noreply.github.com>
2024-06-03 00:59:41 +00:00
Miss Islington (bot) d33b0868d6
[3.13] GH-119054: Add "Reading and writing files" section to pathlib docs (GH-119524) (#119954)
Add a dedicated subsection for `open()`, `read_text()`, `read_bytes()`,
`write_text()` and `write_bytes()`.

(cherry picked from commit bd6d4ed645)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2024-06-02 19:58:41 +00:00
Barney Gale 590fd9ccd4
[3.13] GH-119054: Add "Querying file type and status" section to pathlib docs (GH-119055) (#119951)
Add a dedicated subsection for `Path.stat()`-related methods, specifically
`stat()`, `lstat()`, `exists()`, `is_*()`, and `samefile()`.

(cherry picked from commit 81d6336230)
2024-06-02 20:37:01 +01:00
Miss Islington (bot) cfec22ce19
[3.13] Improve documentation for typing.get_type_hints (GH-119928) (#119943)
- Explicit list of what it does that is different from
  "just return __annotations__"
- Remove reference to PEP 563; adding the future import doesn't
  do anything to type aliases, and in general it will never make
  get_type_hints() less likely to fail.
- Remove example, as the Annotated docs already have a similar
  example, and it's unbalanced to have one example about this
  one edge case but not about other behaviors of the function.

(cherry picked from commit aa9fe98e06)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-06-02 15:29:25 +00:00
Miss Islington (bot) 9d3de7b0ed
[3.13] gh-117657: Fix TSAN reported race in `_PyEval_IsGILEnabled`. (GH-119921) (#119939)
The GIL may be disabled concurrently with this call so we need to use a
relaxed atomic load.
(cherry picked from commit f3b89a63cb)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-06-02 14:42:46 +00:00
Miss Islington (bot) cf8f292a36
[3.13] gh-118934: Fix PyEval_GetLocals docs (PEP 667) (GH-119934)
PEP 667's description of the planned changes to PyEval_GetLocals
was internally inconsistent when accepted, so the docs added for
gh-74929 didn't match either the current behaviour or the intended
behaviour once gh-118934 is fixed.

This PR updates the documentation and 3.13 What's New to match the
intended behaviour (once gh-118934 is fixed).

It also tidies up lingering references to `f_locals` always being a
dictionary (this hasn't been true since at least when custom
namespace support for class statement execution was added)
(cherry picked from commit fd6cd621e0)

Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2024-06-02 05:57:17 +00:00
Miss Islington (bot) 36ca00f44d
[3.13] gh-118888: Further PEP 667 docs updates (gh-119894)
* Clarify impact on default behaviour of exec, eval, etc
* Update documentation for changes to PyEval_GetLocals (gh-74929)

Closes gh-118888
(cherry picked from commit 2180991ea3)

Co-authored-by: Alyssa Coghlan <ncoghlan@gmail.com>
2024-06-02 15:41:25 +10:00
Miss Islington (bot) edb6883ef3
[3.13] gh-119016: Remove outdated sentences from the "classes" tutorial (GH-119130) (#119925)
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2024-06-01 21:35:03 +00: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) 99d0f51e61
[3.13] Add unique() recipe to itertools docs (gh-119911) (gh-119916) 2024-06-01 12:06:04 -05:00
Miss Islington (bot) 9f9be95d66
[3.13] gh-117657: Add TSAN suppression for `set_discard_entry` (GH-119908) (#119914)
Seen in CI occasionally when running `test_weakref`.
(cherry picked from commit 7dc745d1f5)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-06-01 16:42:16 +00: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
Victor Stinner 4e147caf3f
[3.13] Revert "[3.13] gh-69214: Fix fcntl.ioctl() request type (GH-119498) (… (#119906)
Revert "[3.13] gh-69214: Fix fcntl.ioctl() request type (GH-119498) (#119504)"

This reverts commit 0bab0b3a53.

The change modified how negative values, like termios.TIOCSWINSZ, was
treated and is actually backward incompatible.
2024-06-01 17:08:23 +02:00
Miss Islington (bot) 48054d2306
[3.13] gh-117657: Fix TSAN race in QSBR assertion (GH-119887) (#119904)
Due to a limitation in TSAN, all reads from `PyThreadState.state` must be
atomic to avoid reported races.
(cherry picked from commit 90ec19fd33)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-06-01 14:51:55 +00:00
Miss Islington (bot) 48f3378d6c
[3.13] gh-117657: Fix TSAN race in free-threaded GC (GH-119883) (#119903)
Only call `gc_restore_tid()` from stop-the-world contexts.
`worklist_pop()` can be called while other threads are running, so use a
relaxed atomic to modify `ob_tid`.
(cherry picked from commit 60593b2052)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-06-01 14:26:12 +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) 67ac19111f
[3.13] gh-119799: Add missing `_Py_IncRefTotal` to `_Py_NewRefWithLock` (GH-119800) (#119878)
The free-threaded refleak builds were reporting negative refcount deltas
in some tests because of a missing `_Py_NewRefWithLock`.
(cherry picked from commit 879d43b705)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-05-31 19:08:21 +00:00
Miss Islington (bot) a7e81fdfc1
[3.13] gh-119369: Fix deadlock during thread exit in free-threaded build (GH-119528) (#119868)
Release the GIL before calling `_Py_qsbr_unregister`.

The deadlock could occur when the GIL was enabled at runtime. The
`_Py_qsbr_unregister` call might block while holding the GIL because the
thread state was not active, but the GIL was still held.
(cherry picked from commit 078b8c8cf2)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-05-31 14:19:38 -04:00
Miss Islington (bot) 5e8396e684
[3.13] doc: Add glossary entry for "free threading" (GH-119865) (#119874)
(cherry picked from commit 9bc6045842)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-05-31 17:42:36 +00:00
Miss Islington (bot) eb5e19aa68
[3.13] contextlib docs: Clean up redundant 'up' after 'cleanup' (GH-119872)
Reported by Michael Kass on docs@
(cherry picked from commit f3fc800d5f)
2024-05-31 17:39:02 +00:00
Miss Islington (bot) 24e3a8a9a6
[3.13] gh-100117: Fix inaccuracy in documentation of the CodeObject's co_positions field. (GH-119364) (#119869)
gh-100117: Fix inaccuracy in documentation of the CodeObject's co_positions field. (GH-119364)
(cherry picked from commit 015b1fdd0a)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2024-05-31 17:27:55 +00: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) 6e57bd01e0
gh-116145: Updated bundled Tcl/Tk on Windows to 8.6.14 (GH-117030)
(cherry picked from commit 0e8d35b931)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-05-31 12:38:03 +00:00
Miss Islington (bot) 5539bd9df2
[3.13] gh-103194: Fix Tkinter’s Tcl value type handling for Tcl 8.7/9.0 (GH-103846) (GH-119830)
Some of standard Tcl types were renamed, removed, or no longer
registered in Tcl 8.7/9.0. This change fixes automatic conversion of Tcl
values to Python values to avoid returning a Tcl_Obj where the primary
Python types (int, bool, str, bytes) were returned in older Tcl.
(cherry picked from commit 94e9585e99)

Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
2024-05-31 10:42:24 +00: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) 7dae73b21b
[3.13] gh-97747: Improvements to WASM browser REPL. (GH-97665) (GH-119828)
(cherry picked from commit 010aaa32fb)

Co-authored-by: Katie Bell <katie@katharos.id.au>
2024-05-31 11:25:39 +02:00
Miss Islington (bot) 8470593a98
[3.13] gh-119548: Add a 'clear' command to the REPL (GH-119549) (#119552)
gh-119548: Add a 'clear' command to the REPL (GH-119549)
(cherry picked from commit e3bac04c37)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2024-05-31 08:35:21 +00: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) 1e75dc7324
[3.13] Docs: `shutil.rmtree`'s `onerror` has no pending removal version (GH-118947) (#119804)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2024-05-30 20:52:43 +00:00
Miss Islington (bot) 844b535c51
[3.13] gh-109218: Improve documentation for the complex() constructor (GH-119687) (GH-119803)
* Remove the equivalence with real+imag*1j which can be incorrect in corner
  cases (non-finite numbers, the sign of zeroes).
* Separately document the three roles of the constructor: parsing a string,
  converting a number, and constructing a complex from components.
* Document positional-only parameters of complex(), float(), int() and bool()
  as positional-only.
* Add examples for complex() and int().
* Specify the grammar of the string for complex().
* Improve the grammar of the string for float().
* Describe more explicitly the behavior when real and/or imag arguments are
  complex numbers. (This will be deprecated in future.)
(cherry picked from commit ec1ba26460)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-05-30 20:44:20 +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