[Python-checkins] r71045 - in python/branches/py3k: Lib/test/test_multibytecodec.py Misc/NEWS Modules/cjkcodecs/multibytecodec.c
hyeshik.chang
python-checkins at python.org
Thu Apr 2 12:33:17 CEST 2009
Author: hyeshik.chang
Date: Thu Apr 2 12:33:16 2009
New Revision: 71045
Log:
Issue #5640: Fix _multibytecodec so that CJK codecs don't repeat
error replacement returned by codec error callbacks twice in
IncrementalEncoder and StreamWriter.
Modified:
python/branches/py3k/Lib/test/test_multibytecodec.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Modules/cjkcodecs/multibytecodec.c
Modified: python/branches/py3k/Lib/test/test_multibytecodec.py
==============================================================================
--- python/branches/py3k/Lib/test/test_multibytecodec.py (original)
+++ python/branches/py3k/Lib/test/test_multibytecodec.py Thu Apr 2 12:33:16 2009
@@ -112,6 +112,10 @@
self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123')
self.assertEqual(encoder.encode('', True), b'\xa9\xdc')
+ def test_issue5640(self):
+ encoder = codecs.getincrementalencoder('shift-jis')('backslashreplace')
+ self.assertEqual(encoder.encode('\xff'), b'\\xff')
+ self.assertEqual(encoder.encode('\n'), b'\n')
class Test_IncrementalDecoder(unittest.TestCase):
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Thu Apr 2 12:33:16 2009
@@ -58,6 +58,10 @@
Library
-------
+- Issue #5640: Fix _multibytecodec so that CJK codecs don't repeat
+ error substitutions from non-strict codec error callbacks in
+ incrementalencoder and StreamWriter.
+
- Issue #5656: Fix the coverage reporting when running the test suite with
the -T argument.
Modified: python/branches/py3k/Modules/cjkcodecs/multibytecodec.c
==============================================================================
--- python/branches/py3k/Modules/cjkcodecs/multibytecodec.c (original)
+++ python/branches/py3k/Modules/cjkcodecs/multibytecodec.c Thu Apr 2 12:33:16 2009
@@ -506,7 +506,6 @@
outleft = (Py_ssize_t)(buf.outbuf_end - buf.outbuf);
r = codec->encode(state, codec->config, &buf.inbuf, inleft,
&buf.outbuf, outleft, flags);
- *data = buf.inbuf;
if ((r == 0) || (r == MBERR_TOOFEW && !(flags & MBENC_FLUSH)))
break;
else if (multibytecodec_encerror(codec, state, &buf, errors,r))
@@ -536,6 +535,7 @@
if (_PyBytes_Resize(&buf.outobj, finalsize) == -1)
goto errorexit;
+ *data = buf.inbuf;
Py_XDECREF(buf.excobj);
return buf.outobj;
More information about the Python-checkins
mailing list