[Python-checkins] cpython: Fix check_force_ascii()

victor.stinner python-checkins at python.org
Sat Sep 10 02:14:51 EDT 2016


https://hg.python.org/cpython/rev/3b185df3a3e2
changeset:   103554:3b185df3a3e2
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Sep 09 23:11:52 2016 -0700
summary:
  Fix check_force_ascii()

Issue #27938: Normalize aliases of the ASCII encoding, because
_Py_normalize_encoding() now correctly normalize encoding names.

files:
  Python/fileutils.c |  17 +++++++++--------
  1 files changed, 9 insertions(+), 8 deletions(-)


diff --git a/Python/fileutils.c b/Python/fileutils.c
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -104,23 +104,24 @@
     char *loc;
 #if defined(HAVE_LANGINFO_H) && defined(CODESET)
     char *codeset, **alias;
-    char encoding[100];
+    char encoding[20];   /* longest name: "iso_646.irv_1991\0" */
     int is_ascii;
     unsigned int i;
     char* ascii_aliases[] = {
         "ascii",
+        /* Aliases from Lib/encodings/aliases.py */
         "646",
-        "ansi-x3.4-1968",
-        "ansi-x3-4-1968",
-        "ansi-x3.4-1986",
+        "ansi_x3.4_1968",
+        "ansi_x3.4_1986",
+        "ansi_x3_4_1968",
         "cp367",
         "csascii",
         "ibm367",
-        "iso646-us",
-        "iso-646.irv-1991",
-        "iso-ir-6",
+        "iso646_us",
+        "iso_646.irv_1991",
+        "iso_ir_6",
         "us",
-        "us-ascii",
+        "us_ascii",
         NULL
     };
 #endif

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


More information about the Python-checkins mailing list