Issue #10335: Add tokenize.open(), detect the file encoding using
tokenize.detect_encoding() and open it in read only mode.
diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py
index 7053fd9..a4d4ef0 100755
--- a/Lib/tabnanny.py
+++ b/Lib/tabnanny.py
@@ -93,11 +93,8 @@
check(fullname)
return
- with open(file, 'rb') as f:
- encoding, lines = tokenize.detect_encoding(f.readline)
-
try:
- f = open(file, encoding=encoding)
+ f = tokenize.open(file)
except IOError as msg:
errprint("%r: I/O Error: %s" % (file, msg))
return