diff -r fb0ef164f536 -r 698ae46f40a4 eric6/DebugClients/Python/DebugUtilities.py --- a/eric6/DebugClients/Python/DebugUtilities.py Fri Apr 02 11:59:41 2021 +0200 +++ b/eric6/DebugClients/Python/DebugUtilities.py Sat May 01 14:27:20 2021 +0200 @@ -80,7 +80,7 @@ varargs = None if co.co_flags & CO_VARARGS: varargs = co.co_varnames[nargs] - nargs = nargs + 1 + nargs += 1 varkw = None if co.co_flags & CO_VARKEYWORDS: varkw = co.co_varnames[nargs] @@ -193,13 +193,13 @@ for line in f: line = line.strip() if line: - for name in PYTHON_NAMES: - if line.startswith( - '#!/usr/bin/env {0}'.format(name) + for name in PYTHON_NAMES: # __IGNORE_WARNING_Y110__ + if ( + line.startswith( + '#!/usr/bin/env {0}'.format(name)) or + (line.startswith('#!') and name in line) ): return True - elif line.startswith('#!') and name in line: - return True return False else: return False @@ -224,9 +224,8 @@ return False prog = os.path.basename(program).lower() - for pyname in PYTHON_NAMES: - if pyname in prog: - return True + if any(pyname in prog for pyname in PYTHON_NAMES): + return True return ( not isWindowsPlatform() and @@ -309,11 +308,13 @@ if pyname in program: break else: - if not isWindowsPlatform() and startsWithShebang(args[0]): - # insert our interpreter as first argument - args.insert(0, sys.executable) - elif isWindowsPlatform() and args[0].lower().endswith(".py"): - # it is a Python script; insert our interpreter as first argument + if ( + (not isWindowsPlatform() and startsWithShebang(args[0])) or + (isWindowsPlatform() and args[0].lower().endswith(".py")) + ): + # 1. insert our interpreter as first argument if not Windows + # 2. insert our interpreter as first argument if on Windows and + # it is a Python script args.insert(0, sys.executable) # extract list of interpreter arguments, i.e. all arguments before the @@ -444,14 +445,10 @@ buf = '' continue - if state in (DEFAULT, ARG): - if ch == '"': - state = IN_DOUBLE_QUOTE - else: - state = ARG - buf += ch + if state not in (DEFAULT, ARG, IN_DOUBLE_QUOTE): + raise RuntimeError('Illegal condition') - elif state == IN_DOUBLE_QUOTE: + if state == IN_DOUBLE_QUOTE: if ch == '"': if i + 1 < argsLen and args[i + 1] == '"': # Undocumented feature in Windows: @@ -468,7 +465,11 @@ buf += ch else: - raise RuntimeError('Illegal condition') + if ch == '"': + state = IN_DOUBLE_QUOTE + else: + state = ARG + buf += ch if len(buf) > 0 or state != DEFAULT: result.append(buf)