diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py index 0ae5e9f0df2..3a8cd373be1 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 diff --git a/Misc/NEWS b/Misc/NEWS index 66433e4f018..f52ec6d381a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -46,6 +46,9 @@ Core and Builtins Library ------- +- Issue #8774: tabnanny uses the encoding cookie (#coding:...) to use the + correct encoding + - Issue #7507: Quote "!" in pipes.quote(); it is special to some shells. - Issue #8663: distutils.log emulates backslashreplace error handler. Fix