[Python-checkins] r68858 - in python/branches/release30-maint: Lib/test/test_multibytecodec.py Modules/cjkcodecs/multibytecodec.c
antoine.pitrou
python-checkins at python.org
Thu Jan 22 13:09:38 CET 2009
Author: antoine.pitrou
Date: Thu Jan 22 13:09:38 2009
New Revision: 68858
Log:
Merged revisions 68857 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r68857 | antoine.pitrou | 2009-01-22 12:59:55 +0100 (jeu., 22 janv. 2009) | 3 lines
Followup of #4874: also fix multibytecodec.c
........
Modified:
python/branches/release30-maint/ (props changed)
python/branches/release30-maint/Lib/test/test_multibytecodec.py
python/branches/release30-maint/Modules/cjkcodecs/multibytecodec.c
Modified: python/branches/release30-maint/Lib/test/test_multibytecodec.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_multibytecodec.py (original)
+++ python/branches/release30-maint/Lib/test/test_multibytecodec.py Thu Jan 22 13:09:38 2009
@@ -44,7 +44,7 @@
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 @@
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 @@
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:
Modified: python/branches/release30-maint/Modules/cjkcodecs/multibytecodec.c
==============================================================================
--- python/branches/release30-maint/Modules/cjkcodecs/multibytecodec.c (original)
+++ python/branches/release30-maint/Modules/cjkcodecs/multibytecodec.c Thu Jan 22 13:09:38 2009
@@ -612,7 +612,7 @@
const char *data, *errors = NULL;
Py_ssize_t datalen, finalsize;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s*|z:decode",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|z:decode",
codeckwarglist, &pdata, &errors))
return NULL;
data = pdata.buf;
@@ -1038,7 +1038,7 @@
Py_ssize_t wsize, finalsize = 0, size, origpending;
int final = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s*|i:decode",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y*|i:decode",
incrementalkwarglist, &pdata, &final))
return NULL;
data = pdata.buf;
More information about the Python-checkins
mailing list