summaryrefslogtreecommitdiffstats
path: root/Lib/py_compile.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-11-09 01:08:59 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-11-09 01:08:59 (GMT)
commit58c0752a33253641c1423fac2d4ef3f623fbcb46 (patch)
tree2e2ada02342f78d3cc58a4fe23082818c4025b1b /Lib/py_compile.py
parentae4836df6d0ea92d778ef30bd37417d048fc37fc (diff)
downloadcpython-58c0752a33253641c1423fac2d4ef3f623fbcb46.zip
cpython-58c0752a33253641c1423fac2d4ef3f623fbcb46.tar.gz
cpython-58c0752a33253641c1423fac2d4ef3f623fbcb46.tar.bz2
Issue #10335: Add tokenize.open(), detect the file encoding using
tokenize.detect_encoding() and open it in read only mode.
Diffstat (limited to 'Lib/py_compile.py')
-rw-r--r--Lib/py_compile.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
index 111893e..d241434 100644
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -104,9 +104,7 @@ def compile(file, cfile=None, dfile=None, doraise=False):
byte-compile all installed files (or all files in selected
directories).
"""
- with open(file, "rb") as f:
- encoding = tokenize.detect_encoding(f.readline)[0]
- with open(file, encoding=encoding) as f:
+ with tokenize.open(file) as f:
try:
timestamp = int(os.fstat(f.fileno()).st_mtime)
except AttributeError: