summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2008-06-06 12:18:17 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2008-06-06 12:18:17 (GMT)
commitb2750b5d334e9c8d262009069bce41c15803eca0 (patch)
tree2c501adf96b37d3afbc32e6fdc344fade85cf3d5 /Python/pythonrun.c
parent4efb518185d32d573ff65f11b94c6031340a018a (diff)
downloadcpython-b2750b5d334e9c8d262009069bce41c15803eca0.zip
cpython-b2750b5d334e9c8d262009069bce41c15803eca0.tar.gz
cpython-b2750b5d334e9c8d262009069bce41c15803eca0.tar.bz2
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 7fe4cce..24517e4 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;