Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fa3ba4c

Browse files
committed
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.
1 parent bebba50 commit fa3ba4c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Objects/unicodeobject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,7 +3021,8 @@ PyUnicode_Decode(const char *s,
30213021
return PyUnicode_DecodeUTF8Stateful(s, size, errors, NULL);
30223022
else if ((strcmp(lower, "latin-1") == 0) ||
30233023
(strcmp(lower, "latin1") == 0) ||
3024-
(strcmp(lower, "iso-8859-1") == 0))
3024+
(strcmp(lower, "iso-8859-1") == 0) ||
3025+
(strcmp(lower, "iso8859-1") == 0))
30253026
return PyUnicode_DecodeLatin1(s, size, errors);
30263027
#ifdef HAVE_MBCS
30273028
else if (strcmp(lower, "mbcs") == 0)
@@ -3392,7 +3393,8 @@ PyUnicode_AsEncodedString(PyObject *unicode,
33923393
}
33933394
else if ((strcmp(lower, "latin-1") == 0) ||
33943395
(strcmp(lower, "latin1") == 0) ||
3395-
(strcmp(lower, "iso-8859-1") == 0))
3396+
(strcmp(lower, "iso-8859-1") == 0) ||
3397+
(strcmp(lower, "iso8859-1") == 0))
33963398
return _PyUnicode_AsLatin1String(unicode, errors);
33973399
#ifdef HAVE_MBCS
33983400
else if (strcmp(lower, "mbcs") == 0)

0 commit comments

Comments
 (0)