mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
Move check for str-only keys in LOAD_GLOBAL specializations to specialization time. (GH-31659)
This commit is contained in:
parent
10117f1d8c
commit
b35603532b
2 changed files with 14 additions and 15 deletions
|
@ -1219,6 +1219,10 @@ _Py_Specialize_LoadGlobal(
|
|||
goto fail;
|
||||
}
|
||||
PyDictKeysObject * globals_keys = ((PyDictObject *)globals)->ma_keys;
|
||||
if (!DK_IS_UNICODE(globals_keys)) {
|
||||
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_LOAD_GLOBAL_NON_STRING_OR_SPLIT);
|
||||
goto fail;
|
||||
}
|
||||
Py_ssize_t index = _PyDictKeys_StringLookup(globals_keys, name);
|
||||
if (index == DKIX_ERROR) {
|
||||
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_LOAD_GLOBAL_NON_STRING_OR_SPLIT);
|
||||
|
@ -1241,6 +1245,10 @@ _Py_Specialize_LoadGlobal(
|
|||
goto fail;
|
||||
}
|
||||
PyDictKeysObject * builtin_keys = ((PyDictObject *)builtins)->ma_keys;
|
||||
if (!DK_IS_UNICODE(builtin_keys)) {
|
||||
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_LOAD_GLOBAL_NON_STRING_OR_SPLIT);
|
||||
goto fail;
|
||||
}
|
||||
index = _PyDictKeys_StringLookup(builtin_keys, name);
|
||||
if (index == DKIX_ERROR) {
|
||||
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_LOAD_GLOBAL_NON_STRING_OR_SPLIT);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue