diff --git a/contrib/import-checker.py b/contrib/import-checker.py index a0916e8819f6e8afc7e3ac966723811ae4057d44_Y29udHJpYi9pbXBvcnQtY2hlY2tlci5weQ==..a8454e84673641e0132692df2d151a3804e8cc50_Y29udHJpYi9pbXBvcnQtY2hlY2tlci5weQ== 100755 --- a/contrib/import-checker.py +++ b/contrib/import-checker.py @@ -4,6 +4,7 @@ import ast import collections +import io import os import sys @@ -754,7 +755,11 @@ yield src.read(), modname, f, 0 py = True if py or f.endswith('.t'): - with open(f, 'r') as src: + # Strictly speaking we should sniff for the magic header that denotes + # Python source file encoding. But in reality we don't use anything + # other than ASCII (mainly) and UTF-8 (in a few exceptions), so + # simplicity is fine. + with io.open(f, 'r', encoding='utf-8') as src: for script, modname, t, line in embedded(f, modname, src): yield script, modname.encode('utf8'), t, line