Author berker.peksag
Recipients Julian.Gindi, berker.peksag, brett.cannon, davidszotten@gmail.com, eric.snow, ezio.melotti, rhettinger
Date 2014-08-29.00:05:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1409270703.75.0.486632505117.issue21720@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014-08-29 00:05:03berker.peksagsetrecipients: + berker.peksag, brett.cannon, rhettinger, ezio.melotti, eric.snow, Julian.Gindi, davidszotten@gmail.com
2014-08-29 00:05:03berker.peksagsetmessageid: <1409270703.75.0.486632505117.issue21720@psf.upfronthosting.co.za>
2014-08-29 00:05:03berker.peksaglinkissue21720 messages
2014-08-29 00:05:03berker.peksagcreate