]> granicus.if.org Git - python/commitdiff
Issue #8774: tabnanny uses the encoding cookie (#coding:...) to use the correct
authorVictor Stinner <victor.stinner@haypocalc.com>
Fri, 21 May 2010 10:52:08 +0000 (10:52 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Fri, 21 May 2010 10:52:08 +0000 (10:52 +0000)
encoding

Lib/tabnanny.py
Misc/NEWS

index 2c6fb0cb838a5e36a6cf8bdd288a1babac9f3c28..7053fd9398dbbd64b80fbd393d949ed41a9545b2 100755 (executable)
@@ -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
index fb9b52c7384365e906d4c1579aafffe34d2e9602..5ac16dfc07598ad01db8b8583fb374bbc72aefab 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -375,7 +375,10 @@ C-API
 Library
 -------
 
-- Issue #4870: Add an `options` attribute to SSL contexts, as well as 
+- Issue #8774: tabnanny uses the encoding cookie (#coding:...) to use the
+  correct encoding
+
+- Issue #4870: Add an `options` attribute to SSL contexts, as well as
   several ``OP_*`` constants to the `ssl` module.  This allows to selectively
   disable protocol versions, when used in combination with `PROTOCOL_SSLv23`.