Remove the __unicode__ method from exceptions. Allows unicode() to be called
on exception classes. Would require introducing a tp_unicode slot to make it
work otherwise.
Fixes bug #1551432 and will be backported.
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index af07aa8..27d88a0 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -304,6 +304,15 @@
return -1
self.assertRaises(RuntimeError, g)
+ def testUnicodeStrUsage(self):
+ # Make sure both instances and classes have a str and unicode
+ # representation.
+ self.failUnless(str(Exception))
+ self.failUnless(unicode(Exception))
+ self.failUnless(str(Exception('a')))
+ self.failUnless(unicode(Exception(u'a')))
+
+
def test_main():
run_unittest(ExceptionTests)