[Python-checkins] cpython: Issue #18609: Add a fast-path for "iso8859-1" encoding

victor.stinner python-checkins at python.org
Tue Oct 29 11:34:21 CET 2013


http://hg.python.org/cpython/rev/31f9c1481cfa
changeset:   86734:31f9c1481cfa
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Oct 29 11:34:05 2013 +0100
summary:
  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.

files:
  Objects/unicodeobject.c |  6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3021,7 +3021,8 @@
             return PyUnicode_DecodeUTF8Stateful(s, size, errors, NULL);
         else if ((strcmp(lower, "latin-1") == 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);
 #ifdef HAVE_MBCS
         else if (strcmp(lower, "mbcs") == 0)
@@ -3392,7 +3393,8 @@
         }
         else if ((strcmp(lower, "latin-1") == 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);
 #ifdef HAVE_MBCS
         else if (strcmp(lower, "mbcs") == 0)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list