diff options
Diffstat (limited to 'Modules/_codecsmodule.c')
-rw-r--r-- | Modules/_codecsmodule.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c index 495e4ff53a..c0c8857866 100644 --- a/Modules/_codecsmodule.c +++ b/Modules/_codecsmodule.c @@ -179,12 +179,13 @@ escape_encode(PyObject *self, 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 @@ escape_encode(PyObject *self, 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 |