Commits

Walter Dörwald committed f4f5d88

Fall back to using detect_encoding/open on Python 3.0/3.1.

  • Participants
  • Parent commits 459cced

Comments (0)

Files changed (1)

setuptools/command/build_py.py

             return init_py
 
         if sys.version_info >= (3,):
-            # Open with the correct encoding
-            f = tokenize.open(init_py)
+            if sys.version_info >= (3, 3):
+                # Open with the correct encoding
+                f = tokenize.open(init_py)
+            else:
+                # Detect encoding and use it to open the file
+                with open(init_py, 'rb') as f:
+                    (encoding, lines) = tokenize.detect_encoding(f.readline)
+                f = open(init_py,'rU', encoding=encoding)
         else:
             f = open(init_py,'rU')
         if 'declare_namespace' not in f.read():