mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 12:54:29 +08:00
Fix an issue with encoding detection
This commit is contained in:
@@ -96,7 +96,10 @@ def python_bytes_to_unicode(
|
||||
possible_encoding = re.search(br"coding[=:]\s*([-\w.]+)",
|
||||
first_two_lines)
|
||||
if possible_encoding:
|
||||
return possible_encoding.group(1)
|
||||
e = possible_encoding.group(1)
|
||||
if not isinstance(e, str):
|
||||
e = str(e, 'ascii', 'replace')
|
||||
return e
|
||||
else:
|
||||
# the default if nothing else has been set -> PEP 263
|
||||
return encoding
|
||||
|
||||
Reference in New Issue
Block a user