Fixed an issue in Utilities.determinePythonVersion() when handling a spource that had been split into lines already.

Sat, 13 Dec 2014 11:43:31 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 13 Dec 2014 11:43:31 +0100
changeset 3968
19d287451e44
parent 3967
383a043d62ec
child 3970
c16a52652af5

Fixed an issue in Utilities.determinePythonVersion() when handling a spource that had been split into lines already.

Utilities/__init__.py file | annotate | diff | comparison | revisions
--- a/Utilities/__init__.py	Thu Dec 11 19:53:40 2014 +0100
+++ b/Utilities/__init__.py	Sat Dec 13 11:43:31 2014 +0100
@@ -1455,12 +1455,16 @@
             pyVer = 2
         elif ext in py3Ext and ext not in py2Ext:
             pyVer = 3
-        elif source.startswith("#!"):
-            line0 = source.splitlines()[0]
-            if "python3" in line0:
-                pyVer = 3
-            elif "python" in line0:
-                pyVer = 2
+        else:
+            if isinstance(source, basestring):
+                line0 = source.splitlines()[0]
+            else:
+                line0 = source[0]
+            if line0.startswith("#!"):
+                if "python3" in line0:
+                    pyVer = 3
+                elif "python" in line0:
+                    pyVer = 2
         
         if pyVer == 0 and ext in py2Ext + py3Ext:
             pyVer = sys.version_info[0]

eric ide

mercurial