This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author berker.peksag
Recipients Julian.Gindi, berker.peksag, brett.cannon,, eric.snow, ezio.melotti, rhettinger
Date 2014-08-29.00:05:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:

So you can safely remove this check.
Date User Action Args
2014-08-29 00:05:03berker.peksagsetrecipients: + berker.peksag, brett.cannon, rhettinger, ezio.melotti, eric.snow, Julian.Gindi,
2014-08-29 00:05:03berker.peksagsetmessageid: <>
2014-08-29 00:05:03berker.peksaglinkissue21720 messages
2014-08-29 00:05:03berker.peksagcreate