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)
commitc4e6e0a27944893103f78090eb7d026be0f3707d (patch)
tree4db4778856a84f11c162001c4de7617345b8368f /Lib/test/test_exceptions.py
parent9190b6f4a6f4119d6459d04a74f9b1ad511d1ca0 (diff)
downloadcpython-c4e6e0a27944893103f78090eb7d026be0f3707d.zip
cpython-c4e6e0a27944893103f78090eb7d026be0f3707d.tar.gz
cpython-c4e6e0a27944893103f78090eb7d026be0f3707d.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 a485cba..7f55aab 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -431,6 +431,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)), "")
+
def test_badisinstance(self):
# Bug #2542: if issubclass(e, MyException) raises an exception,
# it should be ignored