Use encode to detect if string is valid ASCII

This commit is contained in:
Shadab Zafar 2016-05-28 10:55:58 +05:30 committed by Thomas Kriechbaumer
parent cfb5efc96f
commit 1c82231129
1 changed files with 2 additions and 2 deletions

View File

@ -31,7 +31,7 @@ def parse_pathod(s, use_http2=False):
May raise ParseException
"""
try:
s = s.decode("ascii")
s.encode("ascii")
except UnicodeError:
raise exceptions.ParseException("Spec must be valid ASCII.", 0, 0)
try:
@ -53,7 +53,7 @@ def parse_pathod(s, use_http2=False):
def parse_pathoc(s, use_http2=False):
try:
s = s.decode("ascii")
s.encode("ascii")
except UnicodeError:
raise exceptions.ParseException("Spec must be valid ASCII.", 0, 0)
try: