diff options
Diffstat (limited to 'Lib/encodings')
-rw-r--r-- | Lib/encodings/__init__.py | 1 | ||||
-rw-r--r-- | Lib/encodings/idna.py | 8 | ||||
-rw-r--r-- | Lib/encodings/punycode.py | 10 |
3 files changed, 9 insertions, 10 deletions
diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py index a214190..66bea5c 100644 --- a/Lib/encodings/__init__.py +++ b/Lib/encodings/__init__.py @@ -120,4 +120,3 @@ def search_function(encoding): # Register the search_function in the Python codec registry codecs.register(search_function) - diff --git a/Lib/encodings/idna.py b/Lib/encodings/idna.py index 7e4d04e..62aa450 100644 --- a/Lib/encodings/idna.py +++ b/Lib/encodings/idna.py @@ -19,10 +19,10 @@ def nameprep(label): continue newlabel.append(stringprep.map_table_b2(c)) label = u"".join(newlabel) - + # Normalize label = unicodedata.normalize("NFKC", label) - + # Prohibit for c in label: if stringprep.in_table_c12(c) or \ @@ -139,7 +139,7 @@ def ToUnicode(label): # Step 8: return the result of step 5 return result - + ### Codec APIs class Codec(codecs.Codec): @@ -156,7 +156,7 @@ class Codec(codecs.Codec): return ".".join(result), len(input) def decode(self,input,errors='strict'): - + if errors != 'strict': raise UnicodeError, "Unsupported error handling "+errors diff --git a/Lib/encodings/punycode.py b/Lib/encodings/punycode.py index e7f2d45..82fd458 100644 --- a/Lib/encodings/punycode.py +++ b/Lib/encodings/punycode.py @@ -9,7 +9,7 @@ import codecs ##################### Encoding ##################################### def segregate(str): - """3.1 Basic code point segregation""" + """3.1 Basic code point segregation""" base = [] extended = {} for c in str: @@ -66,7 +66,7 @@ def insertion_unsort(str, extended): oldindex = index delta = 0 oldchar = char - + return result def T(j, bias): @@ -103,7 +103,7 @@ def adapt(delta, first, numchars): divisions += 36 bias = divisions + (36 * delta // (delta + 38)) return bias - + def generate_integers(baselen, deltas): """3.4 Bias adaptation""" @@ -155,7 +155,7 @@ def decode_generalized_number(extended, extpos, bias, errors): return extpos, result w = w * (36 - t) j += 1 - + def insertion_sort(base, extended, errors): """3.2 Insertion unsort coding""" @@ -193,7 +193,7 @@ def punycode_decode(text, errors): base = unicode(base, "ascii", errors) extended = extended.upper() return insertion_sort(base, extended, errors) - + ### Codec APIs class Codec(codecs.Codec): |