[issue33237] Improve AttributeError message for partially initialized module
Serhiy Storchaka
report at bugs.python.org
Sat Oct 20 03:52:13 EDT 2018
Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
Example:
$ cat foo.py
import bar
bar.baz
$ cat bar.py
import foo
baz = 2
$ ./python foo.py
Traceback (most recent call last):
File "foo.py", line 1, in <module>
import bar
File "/home/serhiy/py/cpython/bar.py", line 1, in <module>
import foo
File "/home/serhiy/py/cpython/foo.py", line 2, in <module>
bar.baz
AttributeError: module 'bar' has no attribute 'baz'
Patched:
$ ./python foo.py
Traceback (most recent call last):
File "foo.py", line 1, in <module>
import bar
File "/home/serhiy/py/cpython/bar.py", line 1, in <module>
import foo
File "/home/serhiy/py/cpython/foo.py", line 2, in <module>
bar.baz
AttributeError: partially initialized module 'bar' has no attribute 'baz' (most likely due to a circular import)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33237>
_______________________________________
More information about the Python-bugs-list
mailing list