diff options
| author | Mark Shannon <mark@hotpy.org> | 2022-03-03 15:17:18 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-03 15:17:18 (GMT) |
| commit | b35603532b52e25c91929177191c44c1deb2f765 (patch) | |
| tree | 592cd09949afa7a0bef75b544243a8005de42009 /Python/specialize.c | |
| parent | 10117f1d8cb49ce95493555c06050faf636ccee7 (diff) | |
| download | cpython-b35603532b52e25c91929177191c44c1deb2f765.zip cpython-b35603532b52e25c91929177191c44c1deb2f765.tar.gz cpython-b35603532b52e25c91929177191c44c1deb2f765.tar.bz2 | |
Move check for str-only keys in LOAD_GLOBAL specializations to specialization time. (GH-31659)
Diffstat (limited to 'Python/specialize.c')
| -rw-r--r-- | Python/specialize.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index 5486b5b..6762582 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -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); |
