diff options
author | alain lefroy <none@none> | 2011-07-08 18:04:13 +0200 |
---|---|---|
committer | alain lefroy <none@none> | 2011-07-08 18:04:13 +0200 |
commit | 314ad09be6c99de4e6902fb06fab8cff512a5a23 (patch) | |
tree | a82e5a86be66433f7ffcc42bc232ebff0682a268 /builder.py | |
parent | d6944a6ed9f7e452b2eb079269d212816c6f2f10 (diff) | |
download | astroid-git-314ad09be6c99de4e6902fb06fab8cff512a5a23.tar.gz |
fix file encoding detection with python2.x (closes #70494)
file encoding declaration shall be in a magic *comment*.
from PEP0263::
More precisely, the first or second line must match the regular
expression "coding[:=]\s*([-\w.]+)". The first group of this
expression is then interpreted as encoding name. If the encoding
is unknown to Python, an error is raised during compilation. There
must not be any Python statement on the line that contains the
encoding declaration.
Diffstat (limited to 'builder.py')
-rw-r--r-- | builder.py | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -60,7 +60,7 @@ if sys.version_info >= (3, 0): else: import re - _ENCODING_RGX = re.compile("[^#]*#*.*coding[:=]\s*([^\s]+)") + _ENCODING_RGX = re.compile("\s*#+.*coding[:=]\s*([-\w.]+)") def _guess_encoding(string): """get encoding from a python file as string or return None if not found |