The object's inline values may be marked invalid if the materialized
dict was already initialized and then deleted.
(cherry picked from commit 162b41f577)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-121403: Add notes for PyList_GetXXX APIs about the need for init (gh-121626)
(cherry picked from commit 2bac2b86b1)
Co-authored-by: Donghee Na <donghee.na@python.org>
gh-113993: For string interning, do not rely on (or assert) _Py_IsImmortal (GH-121358)
Older stable ABI extensions are allowed to make immortal objects mortal.
Instead, use `_PyUnicode_STATE` (`interned` and `statically_allocated`).
(cherry picked from commit 956270d08d)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
This reverts commit 0dfb437a32 prior
to the release of 3.13.0b4 to allow for additional review time.
(cherry picked from commit f27593a87c)
Co-authored-by: Ned Deily <nad@python.org>
gh-121791: Check for `NULL` in `MethodDescriptor2_new` in `_testcapi` (GH-121792)
(cherry picked from commit 8b6d475581)
Co-authored-by: sobolevn <mail@sobolevn.me>
When using the ** operator or pow() with Fraction as the base
and an exponent that is not rational, a float, or a complex, the
fraction is no longer converted to a float.
(cherry picked from commit b9965ef282)
Co-authored-by: Joshua Herman <30265+zitterbewegung@users.noreply.github.com>
console.compile with the "single" param throws an exception when
there are multiple statements, never allowing to adding newlines
to a pasted code block (gh-121610)
This adds a few extra checks to allow extending when in an indented
block, and tests for a few examples.
(cherry picked from commit 7d111dac16)
Co-authored-by: saucoide <32314353+saucoide@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
gh-120831: Increase the default minimum supported iOS version to 13.0 (GH-121250)
Increases the default minimum iOS version to 13.0.
(cherry picked from commit 7e91e0dcfe)
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
The fallback repl does not support "exit" without parentheses, so the
test would hang until the timeout expired.
(cherry picked from commit 4134261ab8)
Co-authored-by: Sam Gross <colesbury@gmail.com>
We should maintain the invariant that a zero `ob_tid` implies the
refcount fields are merged.
* Move the assignment in `_Py_MergeZeroLocalRefcount` to immediately
before the refcount merge.
* Update `_PyTrash_thread_destroy_chain` to set `ob_ref_shared` to
`_Py_REF_MERGED` when setting `ob_tid` to zero.
Also check this invariant with assertions in the GC in debug builds.
That uncovered a bug when running out of memory during GC.
(cherry picked from commit d23be3947c)
Co-authored-by: Sam Gross <colesbury@gmail.com>
This avoids messages like:
ThreadSanitizer: starting new threads after multi-threaded fork is not
supported. Dying (set die_after_fork=0 to override)
(cherry picked from commit 82a4dac9f6)
Co-authored-by: Sam Gross <colesbury@gmail.com>
gh-121546: Disable contextvar caching on free-threading build (GH-121740)
(cherry picked from commit e904300882)
Co-authored-by: Ken Jin <kenjin@python.org>
See 6b98b274b6 for an explanation of the problem and solution. Here I've applied the solution to channels.
(cherry picked from commit 8b209fd4f8, AKA gh-121805)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Any cross-interpreter mechanism for passing objects between interpreters must be very careful to respect isolation, even when the object is effectively immutable (e.g. int, str). Here this especially relates to when an interpreter sends one of its objects, and then is destroyed while the inter-interpreter machinery (e.g. queue) still holds a reference to the object.
When I added interpreters.Queue, I dealt with that case (using an atexit hook) by silently removing all items from the queue that were added by the finalizing interpreter.
Later, while working on concurrent.futures.InterpreterPoolExecutor (gh-116430), I noticed it was somewhat surprising when items were silently removed from the queue when the originating interpreter was destroyed. (See my comment on that PR.)
It took me a little while to realize what was going on. I expect that users, which much less context than I have, would experience the same pain.
My approach, here, to improving the situation is to give users three options:
1. return a singleton (interpreters.queues.UNBOUND) from Queue.get() in place of each removed item
2. raise an exception (interpreters.queues.ItemInterpreterDestroyed) from Queue.get() in place of each removed item
3. existing behavior: silently remove each item (i.e. Queue.get() skips each one)
The default will now be (1), but users can still explicitly opt in any of them, including to the silent removal behavior.
The behavior for each item may be set with the corresponding Queue.put() call. and a queue-wide default may be set when the queue is created. (This is the same as I did for "synconly".)
(cherry picked from commit 6b98b274b6, AKA gh-116431)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
It is our general practice to make new optional parameters keyword-only,
even if the existing parameters are all positional-or-keyword. Passing
this parameter as positional would look confusing and could be error-prone
if additional parameters are added in the future.
(cherry picked from commit 50eec501fe)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
gh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result (GH-121661)
(cherry picked from commit bb802db8cf)
Co-authored-by: sobolevn <mail@sobolevn.me>
gh-120642: Move _PyCode_CODE() to the internal C API (GH-121644)
Move _PyCode_CODE() and _PyCode_NBYTES() macros to the internal C API
since they use _Py_CODEUNIT which is only part of the internal C API.
(cherry picked from commit a2bec77d25)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-73159 Added clarifications in multiprocessing docs on that objects are pickled. (GH-121686)
Added explicit comments about that objects are pickled when transmitted via multiprocessing queues and pipes.
(cherry picked from commit b5805892d5)
Co-authored-by: Ulrik Södergren <ulrik@digitalfotografen.se>
The `allocate_weakref` may return NULL when out of memory. We need to
handle that case and propagate the error.
(cherry picked from commit a640a605a8)
Co-authored-by: Sam Gross <colesbury@gmail.com>