[issue33237] Improve AttributeError message for partially initialized module

2018-10-30 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue33237] Improve AttributeError message for partially initialized module

2018-10-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 3e429dcc242e48fa4cbb1a91cf7c416c37b97b4e by Serhiy Storchaka in branch 'master': bpo-33237: Improve AttributeError message for partially initialized module. (GH-6398)

[issue33237] Improve AttributeError message for partially initialized module

2018-10-20 Thread Serhiy Storchaka
Serhiy Storchaka 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 import bar File "/home/serhiy/py/cpython/bar.py", line 1, in import foo File

[issue33237] Improve AttributeError message for partially initialized module

2018-04-10 Thread Nick Coghlan
Nick Coghlan added the comment: The main idea that comes to mind is to cache a reference to `_frozen_importlib._module_locks` in the interpreter state, and do a key lookup in there (since any in-progress import should have a lock allocated to it). That would be a separate

[issue33237] Improve AttributeError message for partially initialized module

2018-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I have applied the Nick's suggestion. Needed to find a place for new test. The code is copied from PyImport_ImportModuleLevelObject(). I'm not happy from how verbose it is. And testing mod.__spec__._initialized adds relatively

[issue33237] Improve AttributeError message for partially initialized module

2018-04-07 Thread Nick Coghlan
Nick Coghlan added the comment: Oops, just realised my suggested text had an extraneous double quote in it due to a copy-and-paste error. Fixed version: AttributeError: partially initialized module 'spam' has no attribute 'ham' (most likely due to a circular import).

[issue33237] Improve AttributeError message for partially initialized module

2018-04-07 Thread Brett Cannon
Brett Cannon added the comment: +1 from me for Nick's suggestion. -- ___ Python tracker ___

[issue33237] Improve AttributeError message for partially initialized module

2018-04-06 Thread Nick Coghlan
Nick Coghlan added the comment: While I like the idea of this change, the "partially initialized" addition is fairly subtle, and relatively easy to miss. Perhaps append "(most likely due to a circular import)" to the partially initialized case?: AttributeError:

[issue33237] Improve AttributeError message for partially initialized module

2018-04-06 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +6104 stage: -> patch review ___ Python tracker ___

[issue33237] Improve AttributeError message for partially initialized module

2018-04-06 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : Cyclic import usually leads to an AttributeError "module 'spam' has no attribute 'ham'" which usually is confusing because in normal case 'spam.ham' exists, and the user can have no ideas why it is disappeared. The proposed