diff -r 13b600dc4ee5 Lib/encodings/__init__.py
--- a/Lib/encodings/__init__.py Thu Dec 15 05:38:46 2016 +0300
+++ b/Lib/encodings/__init__.py Thu Dec 15 18:23:57 2016 +0900
@@ -26,7 +26,7 @@ Written by Marc-Andre Lemburg (mal@lembu
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
-"""#"
+"""
import codecs
import sys
@@ -37,11 +37,23 @@ from . import aliases
_import_tail = ['*']
_aliases = aliases.aliases
+
+_norm_encoding_map = (
+ #0123456789ABCDEF0123456789ABCDEF
+ ' '
+ ' . 0123456789 '
+ ' ABCDEFGHIJKLMNOPQRSTUVWXYZ '
+ ' abcdefghijklmnopqrstuvwxyz '
+ ' '
+ ' '
+ ' '
+ ' ')
+
+
class CodecRegistryError(LookupError, SystemError):
pass
def normalize_encoding(encoding):
-
""" Normalize an encoding name.
Normalization works as follows: all non-alphanumeric
@@ -51,22 +63,13 @@ def normalize_encoding(encoding):
Note that encoding names should be ASCII only; if they do use
non-ASCII characters, these must be Latin-1 compatible.
-
"""
if isinstance(encoding, bytes):
encoding = str(encoding, "ascii")
- chars = []
- punct = False
- for c in encoding:
- if c.isalnum() or c == '.':
- if punct and chars:
- chars.append('_')
- chars.append(c)
- punct = False
- else:
- punct = True
- return ''.join(chars)
+ s = encoding.translate(_norm_encoding_map)
+ return '_'.join(s.split())
+
def search_function(encoding):