Mercurial > cpython-lru_cache-weakref
diff Python/pythonrun.c @ 47496:2284fa89ab08
Move the codec decode type checks to bytes/bytearray.decode().
Use faster PyUnicode_FromEncodedObject() for bytes/bytearray.decode().
Add new PyCodec_KnownEncoding() API.
Add new PyUnicode_AsDecodedUnicode() and PyUnicode_AsEncodedUnicode() APIs.
Add missing PyUnicode_AsDecodedObject() to unicodeobject.h
Fix punicode codec to also work on memoryviews.
| author | Marc-André Lemburg <mal@egenix.com> |
|---|---|
| date | Fri, 06 Jun 2008 12:18:17 +0000 |
| parents | b6b534b828b3 |
| children | 94f64f11fdd0 |
line wrap: on
line diff
--- a/Python/pythonrun.c Fri Jun 06 11:49:51 2008 +0000 +++ b/Python/pythonrun.c Fri Jun 06 12:18:17 2008 +0000 @@ -261,14 +261,10 @@ codeset = nl_langinfo(CODESET); if (codeset && *codeset) { - PyObject *enc = PyCodec_Encoder(codeset); - if (enc) { - codeset = strdup(codeset); - Py_DECREF(enc); - } else { - codeset = NULL; - PyErr_Clear(); - } + if (PyCodec_KnownEncoding(codeset)) + codeset = strdup(codeset); + else + codeset = NULL; } else codeset = NULL;
