already one.
Patch by Dave Malcolm.
self.assertEqual(exc.name, 'somename')
self.assertEqual(exc.path, 'somepath')
+ def test_non_str_argument(self):
+ # Issue #15778
+ arg = b'abc'
+ exc = ImportError(arg)
+ self.assertEqual(str(arg), str(exc))
def test_main():
Core and Builtins
-----------------
+- Issue #15778: ensure that str(ImportError(msg)) returns a str
+ even when msg isn't a str.
+
- Issue #2051: Source file permission bits are once again correctly
copied to the cached bytecode file. (The migration to importlib
reintroduced this problem because these was no regression test. A test
static PyObject *
ImportError_str(PyImportErrorObject *self)
{
- if (self->msg) {
+ if (self->msg && PyUnicode_CheckExact(self->msg)) {
Py_INCREF(self->msg);
return self->msg;
}