[Python-checkins] r81866 - in python/branches/release26-maint: Lib/test/test_codecs.py Misc/NEWS Modules/_codecsmodule.c
philip.jenvey
python-checkins at python.org
Wed Jun 9 19:55:28 CEST 2010
Author: philip.jenvey
Date: Wed Jun 9 19:55:28 2010
New Revision: 81866
Log:
Merged revisions 79779 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79779 | philip.jenvey | 2010-04-04 19:51:51 -0700 (Sun, 04 Apr 2010) | 2 lines
fix escape_encode to return the correct consumed size
........
Modified:
python/branches/release26-maint/ (props changed)
python/branches/release26-maint/Lib/test/test_codecs.py
python/branches/release26-maint/Misc/NEWS
python/branches/release26-maint/Modules/_codecsmodule.c
Modified: python/branches/release26-maint/Lib/test/test_codecs.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_codecs.py (original)
+++ python/branches/release26-maint/Lib/test/test_codecs.py Wed Jun 9 19:55:28 2010
@@ -829,6 +829,9 @@
"UnicodeInternalTest")
self.assertEquals((u"ab", 12), ignored)
+ encoder = codecs.getencoder("string-escape")
+ self.assertEquals(encoder(r'\x00')[1], 4)
+
# From http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html
nameprep_tests = [
# 3.1 Map to nothing.
Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS (original)
+++ python/branches/release26-maint/Misc/NEWS Wed Jun 9 19:55:28 2010
@@ -67,6 +67,8 @@
Library
-------
+- Fix codecs.escape_encode to return the correct consumed size.
+
- Issue #6470: Drop UNC prefix in FixTk.
- Issue #8833: tarfile created hard link entries with a size field != 0 by
Modified: python/branches/release26-maint/Modules/_codecsmodule.c
==============================================================================
--- python/branches/release26-maint/Modules/_codecsmodule.c (original)
+++ python/branches/release26-maint/Modules/_codecsmodule.c Wed Jun 9 19:55:28 2010
@@ -179,12 +179,13 @@
PyObject *str;
const char *errors = NULL;
char *buf;
- Py_ssize_t len;
+ Py_ssize_t consumed, len;
- if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
- &PyString_Type, &str, &errors))
+ if (!PyArg_ParseTuple(args, "S|z:escape_encode",
+ &str, &errors))
return NULL;
+ consumed = PyString_GET_SIZE(str);
str = PyString_Repr(str, 0);
if (!str)
return NULL;
@@ -196,7 +197,7 @@
if (_PyString_Resize(&str, len-2) < 0)
return NULL;
- return codec_tuple(str, PyString_Size(str));
+ return codec_tuple(str, consumed);
}
#ifdef Py_USING_UNICODE
More information about the Python-checkins
mailing list