Fix bug in specialization and make reification atomic

This commit is contained in:
Pablo Galindo Salgado 2025-10-21 16:55:35 +01:00
parent cdec6a6236
commit c3b4807dac
2 changed files with 17 additions and 3 deletions

View file

@ -1708,10 +1708,14 @@ specialize_load_global_lock_held(
goto fail;
}
PyObject *value = NULL;
if (PyDict_GetItemRef(globals, name, &value) < 0 ||
(value != NULL && PyLazyImport_CheckExact(value))) {
if (PyDict_GetItemRef(globals, name, &value) < 0) {
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_EXPECTED_ERROR);
goto fail;
}
if (value != NULL && PyLazyImport_CheckExact(value)) {
SPECIALIZATION_FAIL(LOAD_GLOBAL, SPEC_FAIL_ATTR_MODULE_LAZY_VALUE);
Py_DECREF(value);
goto fail;
}
Py_XDECREF(value);
Py_ssize_t index = _PyDictKeys_StringLookup(globals_keys, name);