]> granicus.if.org Git - python/commitdiff
fix for files with coding cookies and BOMs
authorBenjamin Peterson <benjamin@python.org>
Thu, 18 Mar 2010 22:34:15 +0000 (22:34 +0000)
committerBenjamin Peterson <benjamin@python.org>
Thu, 18 Mar 2010 22:34:15 +0000 (22:34 +0000)
Lib/tokenize.py

index 89721371b998db1ddff4b283799ad1164b0663b9..519dfa5784927c5872f2b1cc82102a456d9f6ef4 100644 (file)
@@ -333,9 +333,11 @@ def detect_encoding(readline):
             # This behaviour mimics the Python interpreter
             raise SyntaxError("unknown encoding: " + encoding)
 
-        if bom_found and codec.name != 'utf-8':
-            # This behaviour mimics the Python interpreter
-            raise SyntaxError('encoding problem: utf-8')
+        if bom_found:
+            if codec.name != 'utf-8':
+                # This behaviour mimics the Python interpreter
+                raise SyntaxError('encoding problem: utf-8')
+            encoding += '-sig'
         return encoding
 
     first = read_or_stop()