Matthias Bussonnier added the comment: I'm unsure I understand changing only the default __str__() method. You will anyway have to format the message differently depending on whether you raise from a from-import or a from-import-* or any other locations.
AFAIU you "just" need the following - PyErr_SetImportError(PyUnicode_FromFormat("cannot import name %R", name), pkgname, pkgpath); + PyErr_SetImportError( + PyUnicode_FromFormat("cannot import name %R from %R (%S)", + name, pkgname, pkgpath), + pkgname, pkgpath); To use Barry format (though keeping quotes around identifiers to match current behavior). (And similar if path is null). I'm unsure if you meant to provide a set of "format-template" to ImportError that are guarantied to be called with format(name=..., path=...) but I doubt it. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29546> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com