Message226047
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. |
|
Date |
User |
Action |
Args |
2014-08-29 00:05:03 | berker.peksag | set | recipients:
+ berker.peksag, brett.cannon, rhettinger, ezio.melotti, eric.snow, Julian.Gindi, davidszotten@gmail.com |
2014-08-29 00:05:03 | berker.peksag | set | messageid: <1409270703.75.0.486632505117.issue21720@psf.upfronthosting.co.za> |
2014-08-29 00:05:03 | berker.peksag | link | issue21720 messages |
2014-08-29 00:05:03 | berker.peksag | create | |
|