Berker Peksag added the comment: Thanks for the patch, David!
+ def test_fromlist_error_messages(self): + # Test for issue #21720: fromlist unicode error messages + try: + __import__('encodings', fromlist=[u'aliases']) + except TypeError as exc: + self.assertIn("must be str, not unicode", str(exc)) You could use assertRaises here: with self.assertRaises(TypeError) as cm: # ... self.assertIn('foo', str(cm.exception)) + if (PyUnicode_Check(item)) { + PyErr_SetString(PyExc_TypeError, + "Item in ``from list'' must be str, not unicode"); + Py_DECREF(item); + return 0; + } I think it would be better to improve the error message in Python/import.c: http://hg.python.org/cpython/file/2.7/Python/import.c#l2571 So you can safely remove this check. ---------- stage: needs patch -> patch review _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21720> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com