Skip to content

Commit 5aefd54

Browse files
itamarometa-codesync[bot]
authored andcommitted
Import upstream 3.14.1 release
Summary: Imported python/cpython `3.14.1` from upstream rev [`57e0d17`](https://www.github.com/python/cpython/commit/57e0d177c26d4a508ef46adae9cbae46fca39f70) (committed 2025-12-02 12:51:18+00:00). # Commit Info Base: (`3.14.0`) - [`ebf955d`](https://www.github.com/python/cpython/commit/ebf955df7a89ed0c7968f79faec1de49f61ed7cb) (commit date: 2025-10-07 09:34:30+00:00) Imported: (`3.14.1`) - [`57e0d17`](https://www.github.com/python/cpython/commit/57e0d177c26d4a508ef46adae9cbae46fca39f70) (commit date: 2025-12-02 12:51:18+00:00) # Files added ``` Apple/.ruff.toml Doc/c-api/curses.rst Doc/c-api/picklebuffer.rst Doc/includes/optional-module.rst InternalDocs/stack_protection.md Lib/ensurepip/_bundled/pip-25.3-py3-none-any.whl Lib/pathlib/_local.py Lib/test/mp_preload_main.py Lib/test/test_free_threading/test_capi.py Lib/test/test_free_threading/test_cprofile.py Lib/test/test_free_threading/test_csv.py Lib/test/test_free_threading/test_dbm_gnu.py Lib/test/test_free_threading/test_io.py Lib/test/test_free_threading/test_mmap.py Lib/test/test_free_threading/test_re.py Lib/test/test_free_threading/test_resource.py Lib/test/test_free_threading/test_uuid.py Misc/NEWS.d/3.14.1.rst Modules/clinic/mmapmodule.c.h Tools/wasm/.ruff.toml ``` # Files removed ``` Lib/ensurepip/_bundled/pip-25.2-py3-none-any.whl Tools/wasm/mypy.ini ``` Reviewed By: fried Differential Revision: D88171463 fbshipit-source-id: 4ac5cf9f358e033fdb27c26afaad87e771a83301
1 parent 265a0a3 commit 5aefd54

3 files changed

Lines changed: 62 additions & 57 deletions

File tree

cinderx/Interpreter/3.14/Includes/generated_cases.c.h

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@
654654
new_frame = _PyFrame_PushUnchecked(tstate, getitem, 2, frame);
655655
new_frame->localsplus[0] = container;
656656
new_frame->localsplus[1] = sub;
657-
frame->return_offset = 6 ;
657+
frame->return_offset = 6u ;
658658
}
659659
// _PUSH_FRAME
660660
{
@@ -1588,7 +1588,7 @@
15881588
if (new_frame == NULL) {
15891589
JUMP_TO_LABEL(error);
15901590
}
1591-
frame->return_offset = 4 ;
1591+
frame->return_offset = 4u ;
15921592
DISPATCH_INLINED(new_frame);
15931593
}
15941594
STACKREFS_TO_PYOBJECTS(arguments, total_args, args_o);
@@ -2646,7 +2646,7 @@
26462646
if (new_frame == NULL) {
26472647
JUMP_TO_LABEL(error);
26482648
}
2649-
assert( 1 == 1);
2649+
assert( 1u == 1);
26502650
frame->return_offset = 1;
26512651
DISPATCH_INLINED(new_frame);
26522652
}
@@ -2927,8 +2927,8 @@
29272927
if (new_frame == NULL) {
29282928
JUMP_TO_LABEL(error);
29292929
}
2930-
assert( 4 == 1 + INLINE_CACHE_ENTRIES_CALL_KW);
2931-
frame->return_offset = 4 ;
2930+
assert( 4u == 1 + INLINE_CACHE_ENTRIES_CALL_KW);
2931+
frame->return_offset = 4u ;
29322932
DISPATCH_INLINED(new_frame);
29332933
}
29342934
STACKREFS_TO_PYOBJECTS(arguments, total_args, args_o);
@@ -7309,7 +7309,7 @@
73097309
gen->gi_exc_state.previous_item = tstate->exc_info;
73107310
tstate->exc_info = &gen->gi_exc_state;
73117311
gen_frame->previous = frame;
7312-
frame->return_offset = (uint16_t)( 2 + oparg);
7312+
frame->return_offset = (uint16_t)( 2u + oparg);
73137313
}
73147314
// _PUSH_FRAME
73157315
{
@@ -7985,7 +7985,7 @@
79857985
if (new_frame == NULL) {
79867986
JUMP_TO_LABEL(error);
79877987
}
7988-
frame->return_offset = 4 ;
7988+
frame->return_offset = 4u ;
79897989
DISPATCH_INLINED(new_frame);
79907990
}
79917991
STACKREFS_TO_PYOBJECTS(arguments, total_args, args_o);
@@ -8206,7 +8206,7 @@
82068206
if (new_frame == NULL) {
82078207
JUMP_TO_LABEL(error);
82088208
}
8209-
assert( 1 == 1);
8209+
assert( 1u == 1);
82108210
frame->return_offset = 1;
82118211
DISPATCH_INLINED(new_frame);
82128212
}
@@ -8357,8 +8357,8 @@
83578357
if (new_frame == NULL) {
83588358
JUMP_TO_LABEL(error);
83598359
}
8360-
assert( 4 == 1 + INLINE_CACHE_ENTRIES_CALL_KW);
8361-
frame->return_offset = 4 ;
8360+
assert( 4u == 1 + INLINE_CACHE_ENTRIES_CALL_KW);
8361+
frame->return_offset = 4u ;
83628362
DISPATCH_INLINED(new_frame);
83638363
}
83648364
STACKREFS_TO_PYOBJECTS(arguments, total_args, args_o);
@@ -9029,7 +9029,13 @@
90299029
}
90309030
// _MAYBE_INSTRUMENT
90319031
{
9032-
if (tstate->tracing == 0) {
9032+
#ifdef Py_GIL_DISABLED
9033+
9034+
int check_instrumentation = 1;
9035+
#else
9036+
int check_instrumentation = (tstate->tracing == 0);
9037+
#endif
9038+
if (check_instrumentation) {
90339039
uintptr_t global_version = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & ~_PY_EVAL_EVENTS_MASK;
90349040
uintptr_t code_version = FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(_PyFrame_GetCode(frame)->_co_instrumentation_version);
90359041
if (code_version != global_version) {
@@ -9763,7 +9769,7 @@
97639769
stack_pointer += -1;
97649770
assert(WITHIN_STACK_BOUNDS());
97659771
new_frame->localsplus[1] = PyStackRef_FromPyObjectNew(name);
9766-
frame->return_offset = 10 ;
9772+
frame->return_offset = 10u ;
97679773
DISPATCH_INLINED(new_frame);
97689774
}
97699775

@@ -12046,7 +12052,13 @@
1204612052
}
1204712053
// _MAYBE_INSTRUMENT
1204812054
{
12049-
if (tstate->tracing == 0) {
12055+
#ifdef Py_GIL_DISABLED
12056+
12057+
int check_instrumentation = 1;
12058+
#else
12059+
int check_instrumentation = (tstate->tracing == 0);
12060+
#endif
12061+
if (check_instrumentation) {
1205012062
uintptr_t global_version = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & ~_PY_EVAL_EVENTS_MASK;
1205112063
uintptr_t code_version = FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(_PyFrame_GetCode(frame)->_co_instrumentation_version);
1205212064
if (code_version != global_version) {
@@ -12246,8 +12258,8 @@
1224612258
gen->gi_frame_state = FRAME_EXECUTING;
1224712259
gen->gi_exc_state.previous_item = tstate->exc_info;
1224812260
tstate->exc_info = &gen->gi_exc_state;
12249-
assert( 2 + oparg <= UINT16_MAX);
12250-
frame->return_offset = (uint16_t)( 2 + oparg);
12261+
assert( 2u + oparg <= UINT16_MAX);
12262+
frame->return_offset = (uint16_t)( 2u + oparg);
1225112263
assert(gen_frame->previous == NULL);
1225212264
gen_frame->previous = frame;
1225312265
DISPATCH_INLINED(gen_frame);
@@ -12347,8 +12359,8 @@
1234712359
gen->gi_frame_state = FRAME_EXECUTING;
1234812360
gen->gi_exc_state.previous_item = tstate->exc_info;
1234912361
tstate->exc_info = &gen->gi_exc_state;
12350-
assert( 2 + oparg <= UINT16_MAX);
12351-
frame->return_offset = (uint16_t)( 2 + oparg);
12362+
assert( 2u + oparg <= UINT16_MAX);
12363+
frame->return_offset = (uint16_t)( 2u + oparg);
1235212364
gen_frame->previous = frame;
1235312365
}
1235412366
// _PUSH_FRAME

cinderx/Interpreter/3.14/ceval.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ do_raise(PyThreadState *tstate, PyObject *exc, PyObject *cause)
135135
"calling %R should have returned an instance of "
136136
"BaseException, not %R",
137137
cause, Py_TYPE(fixed_cause));
138+
Py_DECREF(fixed_cause);
138139
goto raise_error;
139140
}
140141
Py_DECREF(cause);

cinderx/UpstreamBorrow/borrowed-3.14.gen_cached.c

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,6 @@ _PyInterpreterState_GetConfig(PyInterpreterState *interp)
557557
#ifdef Py_GIL_DISABLED
558558
#else
559559
#endif
560-
#ifdef Py_GIL_DISABLED
561-
#else
562-
#endif
563560
#ifdef ENABLE_LAZY_IMPORTS
564561
#endif
565562
#ifdef ENABLE_LAZY_IMPORTS
@@ -1246,8 +1243,8 @@ delitem_common(PyDictObject *mp, Py_hash_t hash, Py_ssize_t ix,
12461243

12471244
ASSERT_CONSISTENT(mp);
12481245
}
1249-
static int
1250-
delitem_knownhash_lock_held(PyObject *op, PyObject *key, Py_hash_t hash)
1246+
int
1247+
_PyDict_DelItem_KnownHash_LockHeld(PyObject *op, PyObject *key, Py_hash_t hash)
12511248
{
12521249
Py_ssize_t ix;
12531250
PyDictObject *mp;
@@ -1816,6 +1813,14 @@ static inline int
18161813
insert_combined_dict(PyInterpreterState *interp, PyDictObject *mp,
18171814
Py_hash_t hash, PyObject *key, PyObject *value)
18181815
{
1816+
// gh-140551: If dict was cleared in _Py_dict_lookup,
1817+
// we have to resize one more time to force general key kind.
1818+
if (DK_IS_UNICODE(mp->ma_keys) && !PyUnicode_CheckExact(key)) {
1819+
if (insertion_resize(interp, mp, 0) < 0)
1820+
return -1;
1821+
assert(DK_KIND(mp->ma_keys) == DICT_KEYS_GENERAL);
1822+
}
1823+
18191824
if (mp->ma_keys->dk_usable <= 0) {
18201825
/* Need to resize. */
18211826
if (insertion_resize(interp, mp, 1) < 0) {
@@ -1868,42 +1873,35 @@ insertdict(PyInterpreterState *interp, PyDictObject *mp,
18681873
PyObject *key, Py_hash_t hash, PyObject *value)
18691874
{
18701875
PyObject *old_value;
1876+
Py_ssize_t ix;
18711877

18721878
ASSERT_DICT_LOCKED(mp);
18731879

1874-
if (DK_IS_UNICODE(mp->ma_keys) && !PyUnicode_CheckExact(key)) {
1875-
if (insertion_resize(interp, mp, 0) < 0)
1876-
goto Fail;
1877-
assert(DK_KIND(mp->ma_keys) == DICT_KEYS_GENERAL);
1878-
}
1879-
1880-
if (_PyDict_HasSplitTable(mp)) {
1881-
Py_ssize_t ix = insert_split_key(mp->ma_keys, key, hash);
1880+
if (_PyDict_HasSplitTable(mp) && PyUnicode_CheckExact(key)) {
1881+
ix = insert_split_key(mp->ma_keys, key, hash);
18821882
if (ix != DKIX_EMPTY) {
18831883
insert_split_value(interp, mp, key, value, ix);
18841884
Py_DECREF(key);
18851885
Py_DECREF(value);
18861886
return 0;
18871887
}
1888-
1889-
/* No space in shared keys. Resize and continue below. */
1890-
if (insertion_resize(interp, mp, 1) < 0) {
1891-
goto Fail;
1892-
}
1888+
// No space in shared keys. Go to insert_combined_dict() below.
18931889
}
1894-
1890+
else {
18951891
#ifdef ENABLE_LAZY_IMPORTS
1896-
Py_ssize_t ix = _Py_dict_lookup_keep_lazy(mp, key, hash, &old_value);
1892+
ix = _Py_dict_lookup_keep_lazy(mp, key, hash, &old_value);
18971893
#else
1898-
Py_ssize_t ix = _Py_dict_lookup(mp, key, hash, &old_value);
1894+
ix = _Py_dict_lookup(mp, key, hash, &old_value);
18991895
#endif
1900-
if (ix == DKIX_ERROR)
1901-
goto Fail;
1896+
if (ix == DKIX_ERROR)
1897+
goto Fail;
1898+
}
19021899

19031900
if (ix == DKIX_EMPTY) {
1904-
assert(!_PyDict_HasSplitTable(mp));
1905-
/* Insert into new slot. */
1906-
assert(old_value == NULL);
1901+
// insert_combined_dict() will convert from non DICT_KEYS_GENERAL table
1902+
// into DICT_KEYS_GENERAL table if key is not Unicode.
1903+
// We don't convert it before _Py_dict_lookup because non-Unicode key
1904+
// may change generic table into Unicode table.
19071905
if (insert_combined_dict(interp, mp, hash, key, value) < 0) {
19081906
goto Fail;
19091907
}
@@ -1992,7 +1990,7 @@ _PyDict_SetItem_LockHeld(PyDictObject *dict, PyObject *name, PyObject *value)
19921990
dict_unhashable_type(name);
19931991
return -1;
19941992
}
1995-
return delitem_knownhash_lock_held((PyObject *)dict, name, hash);
1993+
return _PyDict_DelItem_KnownHash_LockHeld((PyObject *)dict, name, hash);
19961994
} else {
19971995
return setitem_lock_held(dict, name, value);
19981996
}
@@ -2753,6 +2751,8 @@ int init_upstream_borrow(void) {
27532751
#endif
27542752
#ifdef Py_GIL_DISABLED
27552753
#endif
2754+
#ifdef Py_GIL_DISABLED
2755+
#endif
27562756
#ifndef NDEBUG
27572757
#else
27582758
#endif
@@ -2850,6 +2850,10 @@ FUNCNAME(PyObject *self, PyObject *other) \
28502850
#define SLOT1BIN(FUNCNAME, SLOTNAME, DUNDER, RDUNDER) \
28512851
SLOT1BINFULL(FUNCNAME, FUNCNAME, SLOTNAME, DUNDER, RDUNDER)
28522852
#define slot_mp_length slot_sq_length
2853+
#ifndef Py_GIL_DISABLED
2854+
#endif
2855+
#ifndef Py_GIL_DISABLED
2856+
#endif
28532857
#define PyBufferWrapper_CAST(op) ((PyBufferWrapper *)(op))
28542858
#undef TPSLOT
28552859
#undef FLSLOT
@@ -3398,7 +3402,6 @@ _PyLineTable_NextAddressRange(PyCodeAddressRange *range)
33983402
&(runtime)->unicode_state.ids.mutex, \
33993403
&(runtime)->imports.extensions.mutex, \
34003404
&(runtime)->ceval.pending_mainthread.mutex, \
3401-
&(runtime)->ceval.sys_trace_profile_mutex, \
34023405
&(runtime)->atexit.mutex, \
34033406
&(runtime)->audit_hooks.mutex, \
34043407
&(runtime)->allocators.mutex, \
@@ -3452,10 +3455,6 @@ _PyLineTable_NextAddressRange(PyCodeAddressRange *range)
34523455
#endif
34533456
#ifdef Py_GIL_DISABLED
34543457
#endif
3455-
#ifdef Py_GIL_DISABLED
3456-
#endif
3457-
#ifdef Py_GIL_DISABLED
3458-
#endif
34593458
#if defined(Py_REF_DEBUG) && defined(Py_GIL_DISABLED)
34603459
#endif
34613460
#ifdef Py_GIL_DISABLED
@@ -5989,8 +5988,7 @@ analyze_descriptor_load(PyTypeObject *type, PyObject *name, PyObject **descr, un
59895988
PyObject *getattr = _PyType_Lookup(type, &_Py_ID(__getattr__));
59905989
has_getattr = getattr != NULL;
59915990
if (has_custom_getattribute) {
5992-
if (getattro_slot == _Py_slot_tp_getattro &&
5993-
!has_getattr &&
5991+
if (!has_getattr &&
59945992
Py_IS_TYPE(getattribute, &PyFunction_Type)) {
59955993
*descr = getattribute;
59965994
*tp_version = ga_version;
@@ -6483,12 +6481,6 @@ do_specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject*
64836481
return -1;
64846482
case GETATTRIBUTE_IS_PYTHON_FUNCTION:
64856483
{
6486-
#ifndef Py_GIL_DISABLED
6487-
// In free-threaded builds it's possible for tp_getattro to change
6488-
// after the call to analyze_descriptor. That is fine: the version
6489-
// guard will fail.
6490-
assert(type->tp_getattro == _Py_slot_tp_getattro);
6491-
#endif
64926484
assert(Py_IS_TYPE(descr, &PyFunction_Type));
64936485
_PyLoadMethodCache *lm_cache = (_PyLoadMethodCache *)(instr + 1);
64946486
if (!function_check_args(descr, 2, LOAD_ATTR)) {

0 commit comments

Comments
 (0)