@@ -1388,6 +1388,7 @@ specialize_load_global_lock_held(
13881388 SPECIALIZATION_FAIL (LOAD_GLOBAL , SPEC_FAIL_OUT_OF_RANGE );
13891389 goto fail ;
13901390 }
1391+ PyDict_Watch (MODULE_WATCHER_ID , globals );
13911392#ifdef Py_GIL_DISABLED
13921393 maybe_enable_deferred_ref_count (value );
13931394#endif
@@ -1405,11 +1406,15 @@ specialize_load_global_lock_held(
14051406 SPECIALIZATION_FAIL (LOAD_GLOBAL , SPEC_FAIL_LOAD_GLOBAL_NON_STRING_OR_SPLIT );
14061407 goto fail ;
14071408 }
1408- index = _PyDictKeys_StringLookup ( builtin_keys , name );
1409+ index = _PyDict_LookupIndexAndValue (( PyDictObject * ) builtins , name , & value );
14091410 if (index == DKIX_ERROR ) {
14101411 SPECIALIZATION_FAIL (LOAD_GLOBAL , SPEC_FAIL_EXPECTED_ERROR );
14111412 goto fail ;
14121413 }
1414+ if (value != NULL && PyLazyImport_CheckExact (value )) {
1415+ SPECIALIZATION_FAIL (LOAD_GLOBAL , SPEC_FAIL_ATTR_MODULE_LAZY_VALUE );
1416+ goto fail ;
1417+ }
14131418 if (index != (uint16_t )index ) {
14141419 SPECIALIZATION_FAIL (LOAD_GLOBAL , SPEC_FAIL_OUT_OF_RANGE );
14151420 goto fail ;
@@ -1424,6 +1429,7 @@ specialize_load_global_lock_held(
14241429 SPECIALIZATION_FAIL (LOAD_GLOBAL , SPEC_FAIL_OUT_OF_RANGE );
14251430 goto fail ;
14261431 }
1432+ PyDict_Watch (MODULE_WATCHER_ID , globals );
14271433 uint32_t builtins_version = _PyDict_GetKeysVersionForCurrentState (
14281434 interp , (PyDictObject * ) builtins );
14291435 if (builtins_version == 0 ) {
@@ -1434,6 +1440,7 @@ specialize_load_global_lock_held(
14341440 SPECIALIZATION_FAIL (LOAD_GLOBAL , SPEC_FAIL_OUT_OF_RANGE );
14351441 goto fail ;
14361442 }
1443+ PyDict_Watch (MODULE_WATCHER_ID , builtins );
14371444 cache -> index = (uint16_t )index ;
14381445 cache -> module_keys_version = (uint16_t )globals_version ;
14391446 cache -> builtin_keys_version = (uint16_t )builtins_version ;
0 commit comments