mirror of
https://github.com/python/cpython.git
synced 2025-09-03 07:28:59 +00:00
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.
This commit is contained in:
parent
4efb518185
commit
b2750b5d33
8 changed files with 171 additions and 41 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue