Message287804
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. |
|
Date |
User |
Action |
Args |
2017-02-15 00:51:41 | mbussonn | set | recipients:
+ mbussonn, barry, brett.cannon |
2017-02-15 00:51:41 | mbussonn | set | messageid: <1487119901.86.0.718504995242.issue29546@psf.upfronthosting.co.za> |
2017-02-15 00:51:41 | mbussonn | link | issue29546 messages |
2017-02-15 00:51:41 | mbussonn | create | |
|