[issue29546] A more helpful ImportError message

Brett Cannon report at bugs.python.org
Tue Feb 14 19:31:59 EST 2017


Brett Cannon added the comment:

Thanks to Matthias' PR the information is all there in the exception, but the message has not been changed. One idea for this -- depending on how much C code you want to write -- is to provide a default message for __str__() that changes depending on whether 'path' and/or 'name' are set. Then you can just set the attributes in the __init__() and have __str__() take care of providing a common message format. Another option is to do all of that in the __init__() so that BaseException.args continues to have the full error message (but that is added overhead if the __str__() is never taken of the exception). I also have no clue how much C code this would take :) (This is all why I have toyed with the idea of re-implementing the exceptions in Python for easier customization.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29546>
_______________________________________


More information about the Python-bugs-list mailing list