[issue33237] Improve AttributeError message for partially initialized module

Nick Coghlan report at bugs.python.org
Fri Apr 6 11:57:44 EDT 2018


Nick Coghlan <ncoghlan at gmail.com> 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: partially initialized "module 'spam' has no attribute 'ham' (most likely due to a circular import).

Crucially, for folks encountering the error for the first time, that also introduces them to the main phrase they may want to search for: "circular import".

The "most likely" weasel wording stems from the fact that the problem won't always be with the circular import - they may have just straight up referenced the wrong module or the wrong attribute name, so the apparently circular import is an error.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33237>
_______________________________________


More information about the Python-bugs-list mailing list