Skip to content

Commit 704d217

Browse files
committed
Check globals version as well as builtins
1 parent 20daa07 commit 704d217

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Python/specialize.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,16 @@ _Py_Specialize_LoadGlobal(
419419
if (index != (uint16_t)index) {
420420
goto fail;
421421
}
422-
cache1->module_keys_version = _PyDictKeys_GetVersionForCurrentState((PyDictObject *)globals);
423-
uint32_t keys_version = _PyDictKeys_GetVersionForCurrentState((PyDictObject *)builtins);
424-
if (keys_version == 0) {
422+
uint32_t globals_version = _PyDictKeys_GetVersionForCurrentState((PyDictObject *)globals);
423+
if (globals_version == 0) {
424+
goto fail;
425+
}
426+
uint32_t builtins_version = _PyDictKeys_GetVersionForCurrentState((PyDictObject *)builtins);
427+
if (builtins_version == 0) {
425428
goto fail;
426429
}
427-
cache1->builtin_keys_version = keys_version;
430+
cache1->module_keys_version = globals_version;
431+
cache1->builtin_keys_version = builtins_version;
428432
cache0->index = index;
429433
*instr = _Py_MAKECODEUNIT(LOAD_GLOBAL_BUILTIN, _Py_OPARG(*instr));
430434
goto success;

0 commit comments

Comments
 (0)