summaryrefslogtreecommitdiff
path: root/builder.py
diff options
context:
space:
mode:
authoralain lefroy <none@none>2011-07-08 18:04:13 +0200
committeralain lefroy <none@none>2011-07-08 18:04:13 +0200
commit314ad09be6c99de4e6902fb06fab8cff512a5a23 (patch)
treea82e5a86be66433f7ffcc42bc232ebff0682a268 /builder.py
parentd6944a6ed9f7e452b2eb079269d212816c6f2f10 (diff)
downloadastroid-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.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/builder.py b/builder.py
index 799cc7e7..68bd5c30 100644
--- a/builder.py
+++ b/builder.py
@@ -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