Revert commits:
gh-151593: Fix dead lock in PyDict insert_split_key() (#152200)
gh-150490: Raise PyType_Modified for insertion into split dictionary (#150489)
For gh-150489, it violates locking discipline and results in deadlocks,
gh-151593 is an example of it being hit in CI. The attempted fix
gh-152200 avoids the deadlock but introduces a data-race. The race
window is small but can be triggered with pure Python code.
Add the immutable `curses.complexchar` type: a styled wide-character cell — a spacing character optionally followed by combining characters, plus attributes and a color pair. The color pair is stored separately rather than packed into a `chtype` via `COLOR_PAIR()`, so it is not limited to the values that fit alongside the attribute bits. `str(cc)` returns the text; the read-only `attr` and `pair` attributes return its rendition.
Add the window methods `in_wch()` and `getbkgrnd()` — the wide-character counterparts of `inch()` and `getbkgd()` — which return a `complexchar`. (`inch()`/`getbkgd()` can only return a packed `chtype`, so these fill a real gap; this resolves the long-standing gh-83395 request for `in_wch`.)
The existing character-cell methods (`addch`, `insch`, `echochar`, `bkgd`, `bkgdset`, `border`, `box`, `hline`, `vline`) now also accept a `complexchar`. A `complexchar` already carries its own rendition, so passing one together with an explicit `attr` argument raises `TypeError`.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Add the X/Open Curses SCREEN API for driving more than one terminal:
newterm() and set_term(), plus the ncurses extension new_prescr().
A new screen object wraps the C SCREEN. It exposes the terminal's
standard window as screen.stdscr. Each window keeps a reference to its
screen (like a subwindow does to its parent window), so the screen is
deleted automatically once it and all of its windows are unreferenced.
The ncurses use_screen()/use_window() locking helpers are exposed as
the screen.use() and window.use() methods.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace also _PyObject_HashFast() with PyObject_Hash()
in _collections._count_elements().
Rename _PyObject_HashFast() to _PyObject_HashDictKey(),
and mark it as Py_ALWAYS_INLINE.
Only use _PyObject_HashDictKey() on dictionaries.
For AArch64 linux, reduces the total bytes in the code bodies from 489kb to 218kb.
Reduces the size of the stencils files from 394k lines to 167k lines.
Supported encodings: "cp932", "cp949", "cp950", "Big5","EUC-JP",
"GB2312", "GBK", "johab", and "Shift_JIS".
Partially supported encodings (only BMP characters): "Big5-HKSCS",
"EUC_JIS-2004", "EUC_JISX0213", "Shift_JIS-2004", "Shift_JISX0213",
"utf-8-sig" and non-standard aliases like "UTF8" (without hyphen).
The parser now raises ValueError for known unsupported
multi-byte encodings such us "ISO-2022-JP" or "raw-unicode-escape"
instead of failing later, when encounter non-ASCII data.
* Make _Py_ReachedRecursionLimit inline again
* Remove _Py_MakeRecCheck replacing its use with _Py_ReachedRecursionLimit
* Move the check for C stack swtiching into _Py_CheckRecursiveCall
In free-threaded builds, concurrent calls to PyDict_AddWatcher, PyDict_ClearWatcher, PyDict_Watch, and PyDict_Unwatch can race on the shared callback array and the per-dict watcher tags. This change adds a mutex to serialize watcher registration and removal, atomic operations for tag updates, and atomic acquire/release synchronization for callback dispatch in _PyDict_SendEvent.
Also fixes gh-149507, regenerating `configure` for 3.16.
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Zachary Ware <zach@python.org>
* SEND specialization. Adds 2 new specialized instructions:
* SEND_VIRTUAL: for sends to virtual iterators e.g lists and tuples
* SEND_ASYNC_GEN: for sends to async generators
Tweak FOR_ITER_VIRTUAL so that SEND_VIRTUAL and FOR_ITER_VIRTUAL use equivalent guards