diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-01-22 11:59:55 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-01-22 11:59:55 (GMT) |
commit | 44bf631ad9996004cbd3e0cb03dd94febcba950f (patch) | |
tree | 7bcd62f56229eae1d97c30168433e977049f58a9 /Lib | |
parent | 81fabdb437eea29e2616de58e6952b7ef2e5542f (diff) | |
download | cpython-44bf631ad9996004cbd3e0cb03dd94febcba950f.zip cpython-44bf631ad9996004cbd3e0cb03dd94febcba950f.tar.gz cpython-44bf631ad9996004cbd3e0cb03dd94febcba950f.tar.bz2 |
Followup of #4874: also fix multibytecodec.c
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_multibytecodec.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py index 7962d5e..2f64867 100644 --- a/Lib/test/test_multibytecodec.py +++ b/Lib/test/test_multibytecodec.py @@ -44,7 +44,7 @@ class Test_MultibyteCodec(unittest.TestCase): myreplace = lambda exc: ('', sys.maxsize+1) codecs.register_error('test.cjktest', myreplace) self.assertRaises(IndexError, dec, - 'apple\x92ham\x93spam', 'test.cjktest') + b'apple\x92ham\x93spam', 'test.cjktest') def test_codingspec(self): try: @@ -61,6 +61,10 @@ class Test_MultibyteCodec(unittest.TestCase): self.assertRaises(AttributeError, _multibytecodec.MultibyteStreamWriter, None) + def test_decode_unicode(self): + # Trying to decode an unicode string should raise a TypeError + for enc in ALL_CJKENCODINGS: + self.assertRaises(TypeError, codecs.getdecoder(enc), "") class Test_IncrementalEncoder(unittest.TestCase): @@ -146,6 +150,12 @@ class Test_IncrementalDecoder(unittest.TestCase): self.assertRaises(UnicodeDecodeError, decoder.decode, b'', True) self.assertEqual(decoder.decode(b'B@$'), '\u4e16') + def test_decode_unicode(self): + # Trying to decode an unicode string should raise a TypeError + for enc in ALL_CJKENCODINGS: + decoder = codecs.getincrementaldecoder(enc)() + self.assertRaises(TypeError, decoder.decode, "") + class Test_StreamReader(unittest.TestCase): def test_bug1728403(self): try: |