mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
merge 3.2: issue 14629
This commit is contained in:
commit
63c39fe38e
3 changed files with 18 additions and 2 deletions
|
@ -364,9 +364,12 @@ def detect_encoding(readline):
|
|||
|
||||
def find_cookie(line):
|
||||
try:
|
||||
line_string = line.decode('ascii')
|
||||
# Decode as UTF-8. Either the line is an encoding declaration,
|
||||
# in which case it should be pure ASCII, or it must be UTF-8
|
||||
# per default encoding.
|
||||
line_string = line.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
return None
|
||||
raise SyntaxError("invalid or missing encoding declaration")
|
||||
|
||||
matches = cookie_re.findall(line_string)
|
||||
if not matches:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue