summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2008-06-06 12:18:17 +0000
committerMarc-André Lemburg <mal@egenix.com>2008-06-06 12:18:17 +0000
commitb02358e17f67d632258e5ceb962ad8d7d1b6f4aa (patch)
tree9d3d3013f08b5eee43b296b3439705d974dd678c /Python/pythonrun.c
parent39e336ec3cfa778b9ad3595e2f2eeb4574f7c848 (diff)
downloadcpython-b02358e17f67d632258e5ceb962ad8d7d1b6f4aa.tar.gz
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.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 7fe4ccea55..24517e4764 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -261,14 +261,10 @@ Py_InitializeEx(int install_sigs)
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;