eric6/DebugClients/Python/DebugUtilities.py

changeset 7892
bd6b9e401166
parent 7873
cb2badbdf26c
child 7895
554fdb07c856
--- a/eric6/DebugClients/Python/DebugUtilities.py	Thu Dec 17 17:56:35 2020 +0100
+++ b/eric6/DebugClients/Python/DebugUtilities.py	Thu Dec 17 18:17:33 2020 +0100
@@ -188,16 +188,21 @@
     @rtype bool
     """
     try:
-        with open(program) as f:
-            for line in f:
-                line = line.strip()
-                if line:
-                    for name in PYTHON_NAMES:
-                        if line.startswith('#!/usr/bin/env {0}'.format(name)):
-                            return True
-                        elif line.startswith('#!') and name in line:
-                            return True
-                    return False
+        if os.path.exists(program):
+            with open(program) as f:
+                for line in f:
+                    line = line.strip()
+                    if line:
+                        for name in PYTHON_NAMES:
+                            if line.startswith(
+                                '#!/usr/bin/env {0}'.format(name)
+                            ):
+                                return True
+                            elif line.startswith('#!') and name in line:
+                                return True
+                        return False
+        else:
+            return False
     except UnicodeDecodeError:
         return False
     except Exception:

eric ide

mercurial