summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_exceptions.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-04-02 16:15:06 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-04-02 16:15:06 (GMT)
commit9b09ba1234f8ba7a01eaf8986147ae0758712089 (patch)
tree04928077ec795bc7fd41d0e5ab77532bb2092b08 /Lib/test/test_exceptions.py
parent24dfb05d4f7de2d28db2c69560d3afa8f612242c (diff)
downloadcpython-9b09ba1234f8ba7a01eaf8986147ae0758712089.zip
cpython-9b09ba1234f8ba7a01eaf8986147ae0758712089.tar.gz
cpython-9b09ba1234f8ba7a01eaf8986147ae0758712089.tar.bz2
bail in unicode error's __str__ methods if the objects are not properly initialized (closes #21134)
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r--Lib/test/test_exceptions.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 80e921a..61347de 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -800,6 +800,12 @@ class ExceptionTests(unittest.TestCase):
u.start = 1000
self.assertEqual(str(u), "can't translate characters in position 1000-4: 965230951443685724997")
+ def test_unicode_errors_no_object(self):
+ # See issue #21134.
+ klasses = UnicodeDecodeError, UnicodeDecodeError, UnicodeTranslateError
+ for klass in klasses:
+ self.assertEqual(str(klass.__new__(klass)), "")
+
@no_tracing
def test_badisinstance(self):
# Bug #2542: if issubclass(e, MyException) raises an exception,