FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-20490: Improve circular import error messaging by asottile · Pull Request #15308 · python/cpython · GitHub

Repository navigation

bpo-20490: Improve circular import error messaging - #15308

Merged
zooba merged 1 commit into
python:masterfrom
asottile:partially_initialized_bpo_20490
Sep 9, 2019
Merged

zooba merged 1 commit into
python:masterfrom
asottile:partially_initialized_bpo_20490

Conversation

asottile commented Aug 15, 2019 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor Author

This is largely based on the work in https://bugs.python.org/issue33237 by @serhiy-storchaka #6398

Copy link
Copy Markdown
Contributor Author

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)

cool-RR commented Aug 15, 2019

Copy link
Copy Markdown
Contributor

Thanks for working on this @asottile ! If this old idea will come true, that'd be cool.

asottile force-pushed the partially_initialized_bpo_20490 branch from 3d72f86 to 550209c Compare August 15, 2019 20:01
asottile force-pushed the partially_initialized_bpo_20490 branch 2 times, most recently from d56ddb9 to e7b41f9 Compare August 15, 2019 23:11
pablogsal requested a review from brettcannon August 17, 2019 17:20
asottile force-pushed the partially_initialized_bpo_20490 branch 2 times, most recently from 5d18cf9 to efacf0f Compare August 21, 2019 22:41

Copy link
Copy Markdown
Contributor Author

(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 😆)

brettcannon reopened this Aug 23, 2019
Comment thread Python/ceval.c Outdated
Comment thread Python/ceval.c Outdated
asottile force-pushed the partially_initialized_bpo_20490 branch from efacf0f to 6ac3cf1 Compare August 31, 2019 23:44
Comment thread Python/ceval.c Outdated
Comment thread Python/ceval.c Outdated
Comment thread Python/ceval.c Outdated
Comment thread Python/ceval.c Outdated
Comment thread Lib/test/test_import/__init__.py Outdated
asottile force-pushed the partially_initialized_bpo_20490 branch from 6ac3cf1 to 5feaa0c Compare September 1, 2019 00:46
zooba merged commit 65366bc into python:master Sep 9, 2019

Copy link
Copy Markdown
Contributor

Thanks @asottile for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

Copy link
Copy Markdown
Contributor

Sorry @asottile and @zooba, I had trouble checking out the 3.8 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 65366bc8bdc4716ebc361e622590b45a6e5aef07 3.8

Copy link
Copy Markdown

GH-15791 is a backport of this pull request to the 3.8 branch.

asottile deleted the partially_initialized_bpo_20490 branch September 9, 2019 15:22

pablogsal commented Sep 10, 2019 •
edited
Loading

Copy link
Copy Markdown
Member

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/issue38090

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.


Back | FazBrowse Home | New Git URL