New submission from Dave Malcolm: In Python 3.2 and earlier: >>> str(ImportError(b'foo')) "b'foo'"
In Python 3.3: >>> str(ImportError(b'foo')) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: __str__ returned non-string (type bytes) This appears to be due to commit 76272. I'm attaching a patch which fixes it, though perhaps ImportError should type-check the arguments Motivation: This leads to a failure of the test suite for "docutils" when run under Python 3.3 betas, specifically: ====================================================================== ERROR: test_unicode (test_error_reporting.ErrorStringTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/david/coding/python3.3/docutils/trunk/docutils/test3/test_error_reporting.py", line 154, in test_unicode str(ErrorString(ImportError(self.bs)))) File "/home/david/coding/python3.3/docutils/trunk/docutils/build/lib/docutils/utils/error_reporting.py", line 124, in __str__ super(ErrorString, self).__str__()) File "/home/david/coding/python3.3/docutils/trunk/docutils/build/lib/docutils/utils/error_reporting.py", line 74, in __str__ return str(self.data) TypeError: __str__ returned non-string (type bytes) See http://docutils.svn.sourceforge.net/viewvc/docutils/trunk/docutils/test/test_error_reporting.py?revision=7464&view=markup for the test code. Arguably docutils could just pick a different exception subclass. ---------- messages: 169042 nosy: brett.cannon, dmalcolm priority: normal severity: normal status: open title: str(ImportError(b'foo')) fails type: behavior versions: Python 3.3, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15778> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com