Kaydet (Commit) 6493699c authored tarafından Walter Dörwald's avatar Walter Dörwald

Make raise statements PEP 8 compatible.

üst f7afe958
...@@ -35,7 +35,7 @@ def nameprep(label): ...@@ -35,7 +35,7 @@ def nameprep(label):
stringprep.in_table_c7(c) or \ stringprep.in_table_c7(c) or \
stringprep.in_table_c8(c) or \ stringprep.in_table_c8(c) or \
stringprep.in_table_c9(c): stringprep.in_table_c9(c):
raise UnicodeError, "Invalid character %s" % repr(c) raise UnicodeError("Invalid character %r" % c)
# Check bidi # Check bidi
RandAL = map(stringprep.in_table_d1, label) RandAL = map(stringprep.in_table_d1, label)
...@@ -48,14 +48,14 @@ def nameprep(label): ...@@ -48,14 +48,14 @@ def nameprep(label):
# 2) If a string contains any RandALCat character, the string # 2) If a string contains any RandALCat character, the string
# MUST NOT contain any LCat character. # MUST NOT contain any LCat character.
if filter(stringprep.in_table_d2, label): if filter(stringprep.in_table_d2, label):
raise UnicodeError, "Violation of BIDI requirement 2" raise UnicodeError("Violation of BIDI requirement 2")
# 3) If a string contains any RandALCat character, a # 3) If a string contains any RandALCat character, a
# RandALCat character MUST be the first character of the # RandALCat character MUST be the first character of the
# string, and a RandALCat character MUST be the last # string, and a RandALCat character MUST be the last
# character of the string. # character of the string.
if not RandAL[0] or not RandAL[-1]: if not RandAL[0] or not RandAL[-1]:
raise UnicodeError, "Violation of BIDI requirement 3" raise UnicodeError("Violation of BIDI requirement 3")
return label return label
...@@ -70,7 +70,7 @@ def ToASCII(label): ...@@ -70,7 +70,7 @@ def ToASCII(label):
# Skip to step 8. # Skip to step 8.
if 0 < len(label) < 64: if 0 < len(label) < 64:
return label return label
raise UnicodeError, "label too long" raise UnicodeError("label too long")
# Step 2: nameprep # Step 2: nameprep
label = nameprep(label) label = nameprep(label)
...@@ -85,11 +85,11 @@ def ToASCII(label): ...@@ -85,11 +85,11 @@ def ToASCII(label):
# Skip to step 8. # Skip to step 8.
if 0 < len(label) < 64: if 0 < len(label) < 64:
return label return label
raise UnicodeError, "label too long" raise UnicodeError("label too long")
# Step 5: Check ACE prefix # Step 5: Check ACE prefix
if label.startswith(uace_prefix): if label.startswith(uace_prefix):
raise UnicodeError, "Label starts with ACE prefix" raise UnicodeError("Label starts with ACE prefix")
# Step 6: Encode with PUNYCODE # Step 6: Encode with PUNYCODE
label = label.encode("punycode") label = label.encode("punycode")
...@@ -100,7 +100,7 @@ def ToASCII(label): ...@@ -100,7 +100,7 @@ def ToASCII(label):
# Step 8: Check size # Step 8: Check size
if 0 < len(label) < 64: if 0 < len(label) < 64:
return label return label
raise UnicodeError, "label too long" raise UnicodeError("label too long")
def ToUnicode(label): def ToUnicode(label):
# Step 1: Check for ASCII # Step 1: Check for ASCII
...@@ -119,7 +119,7 @@ def ToUnicode(label): ...@@ -119,7 +119,7 @@ def ToUnicode(label):
try: try:
label = label.encode("ascii") label = label.encode("ascii")
except UnicodeError: except UnicodeError:
raise UnicodeError, "Invalid character in IDN label" raise UnicodeError("Invalid character in IDN label")
# Step 3: Check for ACE prefix # Step 3: Check for ACE prefix
if not label.startswith(ace_prefix): if not label.startswith(ace_prefix):
return unicode(label, "ascii") return unicode(label, "ascii")
...@@ -136,7 +136,7 @@ def ToUnicode(label): ...@@ -136,7 +136,7 @@ def ToUnicode(label):
# Step 7: Compare the result of step 6 with the one of step 3 # Step 7: Compare the result of step 6 with the one of step 3
# label2 will already be in lower case. # label2 will already be in lower case.
if label.lower() != label2: if label.lower() != label2:
raise UnicodeError, ("IDNA does not round-trip", label, label2) raise UnicodeError("IDNA does not round-trip", label, label2)
# Step 8: return the result of step 5 # Step 8: return the result of step 5
return result return result
...@@ -148,7 +148,7 @@ class Codec(codecs.Codec): ...@@ -148,7 +148,7 @@ class Codec(codecs.Codec):
if errors != 'strict': if errors != 'strict':
# IDNA is quite clear that implementations must be strict # IDNA is quite clear that implementations must be strict
raise UnicodeError, "unsupported error handling "+errors raise UnicodeError("unsupported error handling "+errors)
if not input: if not input:
return "", 0 return "", 0
...@@ -168,7 +168,7 @@ class Codec(codecs.Codec): ...@@ -168,7 +168,7 @@ class Codec(codecs.Codec):
def decode(self,input,errors='strict'): def decode(self,input,errors='strict'):
if errors != 'strict': if errors != 'strict':
raise UnicodeError, "Unsupported error handling "+errors raise UnicodeError("Unsupported error handling "+errors)
if not input: if not input:
return u"", 0 return u"", 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment