GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-20490: Improve circular import error messaging by asottile · Pull Request #15308 · python/cpython

Conversation

@asottile

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

https://bugs.python.org/issue20490

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Aug 15, 2019
@bedevere-bot bedevere-bot added the awaiting review label Aug 15, 2019
@asottile

asottile commented Aug 15, 2019

Copy link
Copy Markdown
Contributor Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@asottile

asottile commented Aug 15, 2019

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)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cool-RR

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@asottile
asottile force-pushed the partially_initialized_bpo_20490 branch from 3d72f86 to 550209c Compare August 15, 2019 20:01
@asottile asottile mentioned this pull request Aug 15, 2019
bpo-33237: Improve AttributeError message for partially initialized module. #6398
Merged
@asottile
asottile force-pushed the partially_initialized_bpo_20490 branch 2 times, most recently from d56ddb9 to e7b41f9 Compare August 15, 2019 23:11
@pablogsal
pablogsal requested a review from brettcannon August 17, 2019 17:20
@asottile
asottile force-pushed the partially_initialized_bpo_20490 branch 2 times, most recently from 5d18cf9 to efacf0f Compare August 21, 2019 22:41
@asottile

asottile commented Aug 21, 2019

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brettcannon brettcannon closed this Aug 23, 2019
@brettcannon brettcannon reopened this Aug 23, 2019
serhiy-storchaka
serhiy-storchaka reviewed Aug 24, 2019
View reviewed changes
Comment thread Python/ceval.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/ceval.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@asottile
asottile force-pushed the partially_initialized_bpo_20490 branch from efacf0f to 6ac3cf1 Compare August 31, 2019 23:44
ZackerySpytz
ZackerySpytz reviewed Sep 1, 2019
View reviewed changes
Comment thread Python/ceval.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/ceval.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/ceval.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/ceval.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_import/__init__.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@asottile
Improve circular import error messaging
5feaa0c
@asottile
asottile force-pushed the partially_initialized_bpo_20490 branch from 6ac3cf1 to 5feaa0c Compare September 1, 2019 00:46
@asottile
asottile requested a review from serhiy-storchaka September 9, 2019 05:13
@zooba
zooba merged commit 65366bc into python:master Sep 9, 2019
@bedevere-bot bedevere-bot removed the awaiting review label Sep 9, 2019
@zooba zooba added the needs backport to 3.8 label Sep 9, 2019
@miss-islington

miss-islington commented 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.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented Sep 9, 2019

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington miss-islington assigned zooba Sep 9, 2019
zooba pushed a commit to zooba/cpython that referenced this pull request Sep 9, 2019
@asottile @zooba
bpo-20490: Improve circular import error message (pythonGH-15308)
b85c204
@bedevere-bot

bedevere-bot commented Sep 9, 2019

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.8 label Sep 9, 2019
@asottile
asottile deleted the partially_initialized_bpo_20490 branch September 9, 2019 15:22
zooba added a commit that referenced this pull request Sep 9, 2019
@zooba
bpo-20490: Improve circular import error message (GH-15308)
2d5594f
@pablogsal

pablogsal commented Sep 10, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
@asottile @websurfer5
bpo-20490: Improve circular import error message (pythonGH-15308)
95a1596
@hauntsaninja hauntsaninja mentioned this pull request Dec 1, 2023
gh-95754: Better AttributeError on partially initialised module #112577
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ammaraskar ammaraskar ammaraskar left review comments
@brettcannon brettcannon Awaiting requested review from brettcannon
@serhiy-storchaka serhiy-storchaka Awaiting requested review from serhiy-storchaka
+1 more reviewer
@ZackerySpytz ZackerySpytz ZackerySpytz left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@zooba zooba

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

11 participants

@asottile @cool-RR @miss-islington @bedevere-bot @pablogsal @ammaraskar @serhiy-storchaka @ZackerySpytz @brettcannon @zooba @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.