diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2013-11-22 16:05:39 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2013-11-22 16:05:39 (GMT) |
commit | b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00 (patch) | |
tree | b38661db4903b7edc4042e7562b32720dd3687bf /Python/import.c | |
parent | 9e6097ebe7bb99a4a22b949ef4b1563b21ad7166 (diff) | |
download | cpython-b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00.zip cpython-b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00.tar.gz cpython-b523f8433a8982e10eb41a3e2b37ee0e6d6a6e00.tar.bz2 |
Implement PEP 451 (ModuleSpec).
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Python/import.c b/Python/import.c index f0ac051..584b1b4 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1232,7 +1232,8 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals, 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 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals, 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 { |