summaryrefslogtreecommitdiffstats
path: root/Lib/tabnanny.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-21 10:52:08 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-21 10:52:08 (GMT)
commitf0feec2cb684681139ad81acf4a6a541b57a6274 (patch)
tree9b5b5e67cb966cd6064910bd67969063b08fcc04 /Lib/tabnanny.py
parentb52187710e4b486b33624fbde9ba646bc8e925fc (diff)
downloadcpython-f0feec2cb684681139ad81acf4a6a541b57a6274.zip
cpython-f0feec2cb684681139ad81acf4a6a541b57a6274.tar.gz
cpython-f0feec2cb684681139ad81acf4a6a541b57a6274.tar.bz2
Issue #8774: tabnanny uses the encoding cookie (#coding:...) to use the correct
encoding
Diffstat (limited to 'Lib/tabnanny.py')
-rwxr-xr-xLib/tabnanny.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py
index 2c6fb0c..7053fd9 100755
--- a/Lib/tabnanny.py
+++ b/Lib/tabnanny.py
@@ -93,8 +93,11 @@ def check(file):
check(fullname)
return
+ with open(file, 'rb') as f:
+ encoding, lines = tokenize.detect_encoding(f.readline)
+
try:
- f = open(file)
+ f = open(file, encoding=encoding)
except IOError as msg:
errprint("%r: I/O Error: %s" % (file, msg))
return