aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_codecs.py2
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/_codecsmodule.c2
3 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 5d6b5453f55..5db5dcb9816 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -915,6 +915,8 @@ class UnicodeInternalTest(unittest.TestCase):
self.assertEquals(encoder("a")[1], 1)
self.assertEquals(encoder("\xe9\u0142")[1], 2)
+ self.assertEquals(codecs.escape_encode(br'\x00')[1], 4)
+
# From http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html
nameprep_tests = [
# 3.1 Map to nothing.
diff --git a/Misc/NEWS b/Misc/NEWS
index 5fe35fc4667..9638ebd4885 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -57,6 +57,8 @@ C-API
Library
-------
+- Fix codecs.escape_encode to return the correct consumed size.
+
- Issue #8897: Fix sunau module, use bytes to write the header. Patch written
by Thomas Jollans.
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index a23b073d18b..aac44703adf 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -217,7 +217,7 @@ escape_encode(PyObject *self,
}
}
- return codec_tuple(v, PyBytes_Size(v));
+ return codec_tuple(v, size);
}
/* --- Decoder ------------------------------------------------------------ */