mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
fix for files with coding cookies and BOMs
This commit is contained in:
parent
689a558098
commit
1613ed8108
1 changed files with 5 additions and 3 deletions
|
@ -333,9 +333,11 @@ def detect_encoding(readline):
|
|||
# This behaviour mimics the Python interpreter
|
||||
raise SyntaxError("unknown encoding: " + encoding)
|
||||
|
||||
if bom_found and codec.name != 'utf-8':
|
||||
# This behaviour mimics the Python interpreter
|
||||
raise SyntaxError('encoding problem: utf-8')
|
||||
if bom_found:
|
||||
if codec.name != 'utf-8':
|
||||
# This behaviour mimics the Python interpreter
|
||||
raise SyntaxError('encoding problem: utf-8')
|
||||
encoding += '-sig'
|
||||
return encoding
|
||||
|
||||
first = read_or_stop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue