mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #18609: Add a fast-path for "iso8859-1" encoding
On AIX, the locale encoding may be "iso8859-1", which was not a known syntax of the legacy ISO 8859-1 encoding. Using a C codec instead of a Python codec is faster but also avoids tricky issues during Python startup or complex code.
This commit is contained in:
parent
bebba5059c
commit
fa3ba4c3bc
1 changed files with 4 additions and 2 deletions
|
@ -3021,7 +3021,8 @@ PyUnicode_Decode(const char *s,
|
||||||
return PyUnicode_DecodeUTF8Stateful(s, size, errors, NULL);
|
return PyUnicode_DecodeUTF8Stateful(s, size, errors, NULL);
|
||||||
else if ((strcmp(lower, "latin-1") == 0) ||
|
else if ((strcmp(lower, "latin-1") == 0) ||
|
||||||
(strcmp(lower, "latin1") == 0) ||
|
(strcmp(lower, "latin1") == 0) ||
|
||||||
(strcmp(lower, "iso-8859-1") == 0))
|
(strcmp(lower, "iso-8859-1") == 0) ||
|
||||||
|
(strcmp(lower, "iso8859-1") == 0))
|
||||||
return PyUnicode_DecodeLatin1(s, size, errors);
|
return PyUnicode_DecodeLatin1(s, size, errors);
|
||||||
#ifdef HAVE_MBCS
|
#ifdef HAVE_MBCS
|
||||||
else if (strcmp(lower, "mbcs") == 0)
|
else if (strcmp(lower, "mbcs") == 0)
|
||||||
|
@ -3392,7 +3393,8 @@ PyUnicode_AsEncodedString(PyObject *unicode,
|
||||||
}
|
}
|
||||||
else if ((strcmp(lower, "latin-1") == 0) ||
|
else if ((strcmp(lower, "latin-1") == 0) ||
|
||||||
(strcmp(lower, "latin1") == 0) ||
|
(strcmp(lower, "latin1") == 0) ||
|
||||||
(strcmp(lower, "iso-8859-1") == 0))
|
(strcmp(lower, "iso-8859-1") == 0) ||
|
||||||
|
(strcmp(lower, "iso8859-1") == 0))
|
||||||
return _PyUnicode_AsLatin1String(unicode, errors);
|
return _PyUnicode_AsLatin1String(unicode, errors);
|
||||||
#ifdef HAVE_MBCS
|
#ifdef HAVE_MBCS
|
||||||
else if (strcmp(lower, "mbcs") == 0)
|
else if (strcmp(lower, "mbcs") == 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue