a submodule to a name are now supported.
* :exc:`ImportError` now displays module name and module ``__file__`` path when
``from ... import ...`` fails. (Contributed by Matthias Bussonnier in :issue:`29546`.)
+* Circular imports involving absolute imports with binding a submodule to
+ a name are now supported.
+ (Contributed by Serhiy Storchaka in :issue:`30024`.)
+
New Modules
===========
from test.test_import.data.circular_imports.subpkg import util
self.assertIs(util.util, rebinding.util)
+ def test_binding(self):
+ try:
+ import test.test_import.data.circular_imports.binding
+ except ImportError:
+ self.fail('circular import with binding a submodule to a name failed')
+
if __name__ == '__main__':
# Test needs to be a package, so we can do relative imports.
--- /dev/null
+import test.test_import.data.circular_imports.binding2 as binding2
--- /dev/null
+import test.test_import.data.circular_imports.binding as binding
Core and Builtins
-----------------
+- bpo-30024: Circular imports involving absolute imports with binding
+ a submodule to a name are now supported.
+
- bpo-12414: sys.getsizeof() on a code object now returns the sizes
which includes the code struct and sizes of objects which it references.
Patch by Dong-hee Na.
merely needs to bind the result to a name.
If there is a dot in name, we need to split it and emit a
- LOAD_ATTR for each name.
+ IMPORT_FROM for each name.
*/
Py_ssize_t dot = PyUnicode_FindChar(name, '.', 0,
PyUnicode_GET_LENGTH(name), 1);
PyUnicode_GET_LENGTH(name));
if (!attr)
return 0;
- ADDOP_O(c, LOAD_ATTR, attr, names);
+ ADDOP_O(c, IMPORT_FROM, attr, names);
Py_DECREF(attr);
pos = dot + 1;
}