Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 87347:07229c6104b1
Implement PEP 451 (ModuleSpec).
| author | Eric Snow <ericsnowcurrently@gmail.com> |
|---|---|
| date | Fri, 22 Nov 2013 09:05:39 -0700 |
| parents | f7d401eaee0e |
| children |
line wrap: on
line diff
--- a/Python/import.c Fri Nov 22 11:08:25 2013 -0500 +++ b/Python/import.c Fri Nov 22 09:05:39 2013 -0700 @@ -1232,7 +1232,8 @@ int level) { _Py_IDENTIFIER(__import__); - _Py_IDENTIFIER(__initializing__); + _Py_IDENTIFIER(__spec__); + _Py_IDENTIFIER(_initializing); _Py_IDENTIFIER(__package__); _Py_IDENTIFIER(__path__); _Py_IDENTIFIER(__name__); @@ -1426,16 +1427,21 @@ goto error_with_unlock; } else if (mod != NULL) { - PyObject *value; + PyObject *value = NULL; + PyObject *spec; int initializing = 0; Py_INCREF(mod); /* Optimization: only call _bootstrap._lock_unlock_module() if - __initializing__ is true. - NOTE: because of this, __initializing__ must be set *before* + __spec__._initializing is true. + NOTE: because of this, initializing must be set *before* stuffing the new module in sys.modules. */ - value = _PyObject_GetAttrId(mod, &PyId___initializing__); + spec = _PyObject_GetAttrId(mod, &PyId___spec__); + if (spec != NULL) { + value = _PyObject_GetAttrId(spec, &PyId__initializing); + Py_DECREF(spec); + } if (value == NULL) PyErr_Clear(); else {
