Mercurial > cpython-lru_cache-weakref
diff Modules/_codecsmodule.c @ 72475:8beaa9a37387
Implement PEP 393.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Wed, 28 Sep 2011 07:41:54 +0200 |
| parents | 13e6d3cb2ecd |
| children | d76338eacf7c |
line wrap: on
line diff
--- a/Modules/_codecsmodule.c Tue Sep 27 20:52:04 2011 -0500 +++ b/Modules/_codecsmodule.c Wed Sep 28 07:41:54 2011 +0200 @@ -700,12 +700,10 @@ return NULL; str = PyUnicode_FromObject(str); - if (str == NULL) + if (str == NULL || PyUnicode_READY(str) == -1) return NULL; - v = codec_tuple(PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(str), - PyUnicode_GET_SIZE(str), - errors), - PyUnicode_GET_SIZE(str)); + v = codec_tuple(PyUnicode_AsEncodedString(str, "utf-8", errors), + PyUnicode_GET_LENGTH(str)); Py_DECREF(str); return v; }
