-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-20490: Improve circular import error messaging #15308
Conversation
This is largely based on the work in https://bugs.python.org/issue33237 by @serhiy-storchaka #6398 |
demo$ tail -n999 a/*.py
==> a/b.py <==
from a.c import d
e = 1
==> a/c.py <==
from a.b import e
d = 1
==> a/__init__.py <== before$ python3.8 -c 'import a.b'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/x/a/b.py", line 1, in <module>
from a.c import d
File "/tmp/x/a/c.py", line 1, in <module>
from a.b import e
ImportError: cannot import name 'e' from 'a.b' (/tmp/x/a/b.py) after$ ~/workspace/cpython/python -c 'import a.b'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/x/a/b.py", line 1, in <module>
from a.c import d
File "/tmp/x/a/c.py", line 1, in <module>
from a.b import e
ImportError: cannot import name 'e' from 'a.b' (partially initialized module -- most likely due to a circular import) (/tmp/x/a/b.py) |
Thanks for working on this @asottile ! If this old idea will come true, that'd be cool. |
3d72f86
to
550209c
Compare
d56ddb9
to
e7b41f9
Compare
5d18cf9
to
efacf0f
Compare
(I'm rebasing to presumably fix the CI failure -- it doesn't seem related to my change, but I've been surprised before by macos 😆) |
efacf0f
to
6ac3cf1
Compare
6ac3cf1
to
5feaa0c
Compare
Sorry @asottile and @zooba, I had trouble checking out the |
GH-15791 is a backport of this pull request to the 3.8 branch. |
This pull request introduced a reference leak: https://buildbot.python.org/all/#/builders/1/builds/710 This is being tracked in: |
https://bugs.python.org/issue20490