Sun, 06 Oct 2013 18:02:21 +0200
Continued to shorten the code lines to max. 79 characters.
--- a/DebugClients/Python/AsyncFile.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python/AsyncFile.py Sun Oct 06 18:02:21 2013 +0200 @@ -4,7 +4,8 @@ # """ -Module implementing an asynchronous file like socket interface for the debugger. +Module implementing an asynchronous file like socket interface for the +debugger. """ import socket @@ -98,7 +99,8 @@ """ Public method to close the file. - @param closeit flag to indicate a close ordered by the debugger code (boolean) + @param closeit flag to indicate a close ordered by the debugger code + (boolean) """ if closeit and not self.closed: self.flush() @@ -275,10 +277,11 @@ self.wpending = s elif type(self.wpending) != type(s) or \ len(self.wpending) + len(s) > self.maxbuffersize: - # flush wpending so that different string types are not concatenated + # flush wpending so that different string types are not + # concatenated while self.wpending: - # if we have a persistent error in sending the data, an exception - # will be raised in __nWrite + # if we have a persistent error in sending the data, an + # exception will be raised in __nWrite self.flush() tries += 1 if tries > self.maxtries:
--- a/DebugClients/Python/DCTestResult.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python/DCTestResult.py Sun Oct 06 18:02:21 2013 +0200 @@ -108,7 +108,8 @@ self.parent.write('%s\n' % ResponseUTStopTest) # ensure that pending input is processed - rrdy, wrdy, xrdy = select.select([self.parent.readstream], [], [], 0.01) + rrdy, wrdy, xrdy = select.select([self.parent.readstream], [], [], + 0.01) if self.parent.readstream in rrdy: self.parent.readReady(self.parent.readstream.fileno())
--- a/DebugClients/Python/DebugBase.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python/DebugBase.py Sun Oct 06 18:02:21 2013 +0200 @@ -14,8 +14,8 @@ import atexit import inspect -from DebugProtocol import ResponseClearWatch, ResponseClearBreak, ResponseLine, \ - ResponseSyntax, ResponseException, CallTrace +from DebugProtocol import ResponseClearWatch, ResponseClearBreak, \ + ResponseLine, ResponseSyntax, ResponseException, CallTrace gRecursionLimit = 64 @@ -402,8 +402,8 @@ Private method to determine, if a watch expression is effective. @param frame the current execution frame - @return tuple of watch expression and a flag to indicate, that a temporary - watch expression may be deleted (bdb.Breakpoint, boolean) + @return tuple of watch expression and a flag to indicate, that a + temporary watch expression may be deleted (bdb.Breakpoint, boolean) """ possibles = bdb.Breakpoint.bplist["Watch", 0] for i in range(0, len(possibles)): @@ -411,7 +411,8 @@ if b.enabled == 0: continue if not b.cond: - # watch expression without expression shouldn't occur, just ignore it + # watch expression without expression shouldn't occur, + # just ignore it continue try: val = eval(b.condition, frame.f_globals, frame.f_locals) @@ -501,7 +502,8 @@ def get_break(self, filename, lineno): """ - Reimplemented from bdb.py to get the first breakpoint of a particular line. + Reimplemented from bdb.py to get the first breakpoint of a particular + line. Because eric5 supports only one breakpoint per line, this overwritten method will return this one and only breakpoint. @@ -523,7 +525,8 @@ @param lineno linenumber of the bp """ self.clear_break(filename, lineno) - self._dbgClient.write('%s%s,%d\n' % (ResponseClearBreak, filename, lineno)) + self._dbgClient.write('%s%s,%d\n' % (ResponseClearBreak, filename, + lineno)) def getStack(self): """ @@ -653,7 +656,8 @@ realSyntaxError = os.path.exists(filename) if realSyntaxError: - self._dbgClient.write("%s%s\n" % (ResponseSyntax, unicode(exclist))) + self._dbgClient.write("%s%s\n" % (ResponseSyntax, + unicode(exclist))) self._dbgClient.eventLoop() return
--- a/DebugClients/Python/DebugClientBase.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python/DebugClientBase.py Sun Oct 06 18:02:21 2013 +0200 @@ -29,7 +29,7 @@ DebugClientInstance = None -################################################################################ +############################################################################### def DebugClientRawInput(prompt="", echo=1): @@ -56,7 +56,7 @@ DebugClientOrigRawInput = __main__.__builtins__.__dict__['raw_input'] __main__.__builtins__.__dict__['raw_input'] = DebugClientRawInput -################################################################################ +############################################################################### def DebugClientInput(prompt=""): @@ -82,7 +82,7 @@ DebugClientOrigInput = __main__.__builtins__.__dict__['input'] __main__.__builtins__.__dict__['input'] = DebugClientInput -################################################################################ +############################################################################### def DebugClientFork(): @@ -101,7 +101,7 @@ DebugClientOrigFork = os.fork os.fork = DebugClientFork -################################################################################ +############################################################################### def DebugClientClose(fd): @@ -120,7 +120,7 @@ DebugClientOrigClose = os.close os.close = DebugClientClose -################################################################################ +############################################################################### def DebugClientSetRecursionLimit(limit): @@ -139,15 +139,15 @@ sys.setrecursionlimit = DebugClientSetRecursionLimit DebugClientSetRecursionLimit(sys.getrecursionlimit()) -################################################################################ +############################################################################### class DebugClientBase(object): """ Class implementing the client side of the debugger. - It provides access to the Python interpeter from a debugger running in another - process whether or not the Qt event loop is running. + It provides access to the Python interpeter from a debugger running in + another process whether or not the Qt event loop is running. The protocol between the debugger and the client assumes that there will be a single source of debugger commands and a single source of Python @@ -160,12 +160,11 @@ See DebugProtocol.py for a listing of valid protocol tokens. A Python statement consists of the statement to execute, followed (in a - separate line) by >OK?<. If the statement was incomplete then the response - is >Continue<. If there was an exception then the response is - >Exception<. - Otherwise the response is >OK<. The reason for the >OK?< part is to - provide a sentinal (ie. the responding >OK<) after any possible output as a - result of executing the command. + separate line) by >OK?<. If the statement was incomplete then the + response is >Continue<. If there was an exception then the response + is >Exception<. Otherwise the response is >OK<. The reason + for the >OK?< part is to provide a sentinal (ie. the responding + >OK<) after any possible output as a result of executing the command. The client may send any other lines at any other time which should be interpreted as program output. @@ -174,8 +173,8 @@ The client may close the session at any time as a result of the script being debugged closing or crashing. - <b>Note</b>: This class is meant to be subclassed by individual DebugClient classes. - Do not instantiate it directly. + <b>Note</b>: This class is meant to be subclassed by individual + DebugClient classes. Do not instantiate it directly. """ clientCapabilities = DebugClientCapabilities.HasAll @@ -193,7 +192,8 @@ # dictionary of all threads running self.threads = {} - # the "current" thread, basically the thread we are at a breakpoint for. + # the "current" thread, basically the thread we are at a + # breakpoint for. self.currentThread = self # special objects representing the main scripts thread and frame @@ -295,7 +295,8 @@ This is just an empty function and is overridden in the threaded debugger. - @param target the start function of the target thread (i.e. the user code) + @param target the start function of the target thread (i.e. the user + code) @param args arguments to pass to target @param kwargs keyword arguments to pass to target @param mainThread non-zero, if we are attaching to the already @@ -309,7 +310,8 @@ Public method to send the list of threads. """ threadList = [] - if self.threads and self.currentThread: # indication for the threaded debugger + if self.threads and self.currentThread: + # indication for the threaded debugger currentId = self.currentThread.get_ident() for t in self.threads.values(): d = {} @@ -336,7 +338,8 @@ @param echo Flag indicating echoing of the input (boolean) @return the entered string """ - self.write("%s%s\n" % (DebugProtocol.ResponseRaw, unicode((prompt, echo)))) + self.write("%s%s\n" % (DebugProtocol.ResponseRaw, + unicode((prompt, echo)))) self.inRawMode = 1 self.eventLoop(True) return self.rawLine @@ -360,7 +363,8 @@ def sessionClose(self, exit=1): """ - Public method to close the session with the debugger and optionally terminate. + Public method to close the session with the debugger and optionally + terminate. @param exit flag indicating to terminate (boolean) """ @@ -388,8 +392,8 @@ """ Public method to handle the receipt of a complete line. - It first looks for a valid protocol token at the start of the line. Thereafter - it trys to execute the lines accumulated so far. + It first looks for a valid protocol token at the start of the line. + Thereafter it trys to execute the lines accumulated so far. @param line the received line """ @@ -426,7 +430,8 @@ self.setCurrentThread(tid) self.write(DebugProtocol.ResponseThreadSet + '\n') stack = self.currentThread.getStack() - self.write('%s%s\n' % (DebugProtocol.ResponseStack, unicode(stack))) + self.write('%s%s\n' % (DebugProtocol.ResponseStack, + unicode(stack))) return if cmd == DebugProtocol.RequestStep: @@ -471,7 +476,8 @@ if self.debugging: self.callTraceEnabled = callTraceEnabled else: - self.__newCallTraceEnabled = callTraceEnabled # remember for later + self.__newCallTraceEnabled = callTraceEnabled + # remember for later return if cmd == DebugProtocol.RequestEnv: @@ -512,21 +518,24 @@ # we report on all unhandled exceptions sys.excepthook = self.__unhandled_exception - # clear all old breakpoints, they'll get set after we have started + # clear all old breakpoints, they'll get set after we + # have started self.mainThread.clear_all_breaks() self.mainThread.tracePython = tracePython # This will eventually enter a local event loop. - # Note the use of backquotes to cause a repr of self.running. The - # need for this is on Windows os where backslash is the path separator. - # They will get inadvertantly stripped away during the eval causing - # IOErrors, if self.running is passed as a normal str. + # Note the use of backquotes to cause a repr of self.running. + # The need for this is on Windows os where backslash is the + # path separator. They will get inadvertantly stripped away + # during the eval causing IOErrors, if self.running is passed + # as a normal str. self.debugMod.__dict__['__file__'] = self.running sys.modules['__main__'] = self.debugMod self.callTraceEnabled = self.__newCallTraceEnabled - res = self.mainThread.run('execfile(' + repr(self.running) + ')', - self.debugMod.__dict__) + res = self.mainThread.run( + 'execfile(' + repr(self.running) + ')', + self.debugMod.__dict__) self.progTerminated(res) return @@ -663,7 +672,8 @@ compile(cond, '<string>', 'eval') except SyntaxError: self.write('%s%s,%d\n' % \ - (DebugProtocol.ResponseBPConditionError, fn, line)) + (DebugProtocol.ResponseBPConditionError, fn, + line)) return self.mainThread.set_break(fn, line, temporary, cond) else: @@ -741,8 +751,9 @@ if cmd == DebugProtocol.RequestEval: try: - value = eval(arg, self.currentThread.getCurrentFrame().f_globals, - self.currentThread.getCurrentFrameLocals()) + value = eval( + arg, self.currentThread.getCurrentFrame().f_globals, + self.currentThread.getCurrentFrameLocals()) except: # Report the exception and the traceback try: @@ -806,7 +817,8 @@ return if cmd == DebugProtocol.RequestCapabilities: - self.write('%s%d, "Python"\n' % (DebugProtocol.ResponseCapabilities, + self.write('%s%d, "Python"\n' % ( + DebugProtocol.ResponseCapabilities, self.__clientCapabilities())) return @@ -908,7 +920,8 @@ except (OverflowError, SyntaxError, ValueError): # Report the exception sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info() - map(self.write, traceback.format_exception_only(sys.last_type, sys.last_value)) + map(self.write, traceback.format_exception_only( + sys.last_type, sys.last_value)) self.buffer = '' else: if code is None: @@ -938,7 +951,8 @@ cf = cf.f_back frmnr -= 1 _globals = cf.f_globals - _locals = self.currentThread.getCurrentFrameLocals() + _locals = \ + self.currentThread.getCurrentFrameLocals() # reset sys.stdout to our redirector (unconditionally) if "sys" in _globals: __stdout = _globals["sys"].stdout @@ -987,7 +1001,8 @@ pass return self.clientCapabilities except ImportError: - return self.clientCapabilities & ~DebugClientCapabilities.HasProfiler + return (self.clientCapabilities & + ~DebugClientCapabilities.HasProfiler) def write(self, s): """ @@ -1095,10 +1110,12 @@ being debugged redirects them itself. @param port the port number to connect to (int) - @param remoteAddress the network address of the debug server host (string) - @param redirect flag indicating redirection of stdin, stdout and stderr (boolean) + @param remoteAddress the network address of the debug server host + (string) + @param redirect flag indicating redirection of stdin, stdout and + stderr (boolean) """ - if remoteAddress is None: # default: 127.0.0.1 + if remoteAddress is None: # default: 127.0.0.1 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((DebugProtocol.DebugAddress, port)) else: @@ -1106,13 +1123,13 @@ remoteAddress, index = remoteAddress.split("@@i") else: index = 0 - if ":" in remoteAddress: # IPv6 + if ":" in remoteAddress: # IPv6 sockaddr = socket.getaddrinfo( remoteAddress, port, 0, 0, socket.SOL_TCP)[0][-1] sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) sockaddr = sockaddr[:-1] + (int(index),) sock.connect(sockaddr) - else: # IPv4 + else: # IPv4 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((remoteAddress, port)) @@ -1185,7 +1202,8 @@ Public method to check if a file should be skipped. @param fn filename to be checked - @return non-zero if fn represents a file we are 'skipping', zero otherwise. + @return non-zero if fn represents a file we are 'skipping', + zero otherwise. """ if self.mainThread.tracePython: # trace into Python library return 0 @@ -1237,9 +1255,11 @@ """ Private method to return the variables of a frame to the debug server. - @param frmnr distance of frame reported on. 0 is the current frame (int) + @param frmnr distance of frame reported on. 0 is the current frame + (int) @param scope 1 to report global variables, 0 for local variables (int) - @param filter the indices of variable types to be filtered (list of int) + @param filter the indices of variable types to be filtered (list of + int) """ if self.currentThread is None: return @@ -1272,16 +1292,20 @@ vlist = self.__formatVariablesList(keylist, dict, scope, filter) varlist.extend(vlist) - self.write('%s%s\n' % (DebugProtocol.ResponseVariables, unicode(varlist))) + self.write('%s%s\n' % ( + DebugProtocol.ResponseVariables, unicode(varlist))) def __dumpVariable(self, var, frmnr, scope, filter): """ Private method to return the variables of a frame to the debug server. - @param var list encoded name of the requested variable (list of strings) - @param frmnr distance of frame reported on. 0 is the current frame (int) + @param var list encoded name of the requested variable + (list of strings) + @param frmnr distance of frame reported on. 0 is the current frame + (int) @param scope 1 to report global variables, 0 for local variables (int) - @param filter the indices of variable types to be filtered (list of int) + @param filter the indices of variable types to be filtered + (list of int) """ if self.currentThread is None: return @@ -1389,7 +1413,8 @@ if "PyQt4." in str(type(obj)): qtVariable = True qvar = obj - qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1] + qvtype = ("%s" % type(qvar))[1:-1]\ + .split()[1][1:-1] except: pass try: @@ -1414,7 +1439,8 @@ if "PyQt4." in str(type(obj)): qtVariable = True qvar = obj - qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1] + qvtype = ("%s" % type(qvar))[1:-1]\ + .split()[1][1:-1] except: pass else: @@ -1426,7 +1452,8 @@ if "PyQt4." in str(type(obj)): qtVariable = True qvar = obj - qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1] + qvtype = ("%s" % type(qvar))[1:-1]\ + .split()[1][1:-1] except: pass try: @@ -1442,7 +1469,8 @@ if "PyQt4." in str(type(obj)): qtVariable = True qvar = obj - qvtype = ("%s" % type(qvar))[1:-1].split()[1][1:-1] + qvtype = ("%s" % type(qvar))[1:-1]\ + .split()[1][1:-1] except: pass odict = dict @@ -1495,8 +1523,8 @@ dictkeys = dict.keys() else: dictkeys = range(len(dict)) - vlist = self.__formatVariablesList(dictkeys, dict, scope, filter, - formatSequences) + vlist = self.__formatVariablesList( + dictkeys, dict, scope, filter, formatSequences) varlist.extend(vlist) if obj is not None and not formatSequences: @@ -1510,7 +1538,8 @@ except: pass - self.write('%s%s\n' % (DebugProtocol.ResponseVariable, unicode(varlist))) + self.write('%s%s\n' % ( + DebugProtocol.ResponseVariable, unicode(varlist))) def __formatQt4Variable(self, value, vtype): """ @@ -1566,7 +1595,8 @@ h, s, v, a = value.getHsv() varlist.append(("hsv", "int", "%d, %d, %d, %d" % (h, s, v, a))) c, m, y, k, a = value.getCmyk() - varlist.append(("cmyk", "int", "%d, %d, %d, %d, %d" % (c, m, y, k, a))) + varlist.append( + ("cmyk", "int", "%d, %d, %d, %d, %d" % (c, m, y, k, a))) elif qttype == 'QDate': varlist.append(("", "QDate", "%s" % value.toString())) elif qttype == 'QTime': @@ -1575,8 +1605,10 @@ varlist.append(("", "QDateTime", "%s" % value.toString())) elif qttype == 'QDir': varlist.append(("path", "str", "%s" % value.path())) - varlist.append(("absolutePath", "str", "%s" % value.absolutePath())) - varlist.append(("canonicalPath", "str", "%s" % value.canonicalPath())) + varlist.append( + ("absolutePath", "str", "%s" % value.absolutePath())) + varlist.append( + ("canonicalPath", "str", "%s" % value.canonicalPath())) elif qttype == 'QFile': varlist.append(("fileName", "str", "%s" % value.fileName())) elif qttype == 'QFont': @@ -1598,7 +1630,8 @@ if value.isValid(): varlist.append(("row", "int", "%s" % value.row())) varlist.append(("column", "int", "%s" % value.column())) - varlist.append(("internalId", "int", "%s" % value.internalId())) + varlist.append( + ("internalId", "int", "%s" % value.internalId())) varlist.append(("internalPointer", "void *", "%s" % \ value.internalPointer())) elif qttype == 'QRegExp': @@ -1611,7 +1644,8 @@ varlist.append(("icon text", "str", "%s" % value.iconText())) varlist.append(("tooltip", "str", "%s" % value.toolTip())) varlist.append(("whatsthis", "str", "%s" % value.whatsThis())) - varlist.append(("shortcut", "str", "%s" % value.shortcut().toString())) + varlist.append( + ("shortcut", "str", "%s" % value.shortcut().toString())) elif qttype == 'QKeySequence': varlist.append(("value", "", "%s" % value.toString())) @@ -1633,7 +1667,8 @@ # Networking stuff elif qttype == 'QHostAddress': - varlist.append(("address", "QHostAddress", "%s" % value.toString())) + varlist.append( + ("address", "QHostAddress", "%s" % value.toString())) return varlist @@ -1644,24 +1679,25 @@ The dictionary passed in to it is scanned. Variables are only added to the list, if their type is not contained - in the filter list and their name doesn't match any of the filter expressions. - The formated variables list (a list of tuples of 3 values) is returned. + in the filter list and their name doesn't match any of + the filter expressions. The formated variables list (a list of tuples + of 3 values) is returned. @param keylist keys of the dictionary @param dict the dictionary to be scanned @param scope 1 to filter using the globals filter, 0 using the locals filter (int). - Variables are only added to the list, if their name do not match any of the - filter expressions. - @param filter the indices of variable types to be filtered. Variables are - only added to the list, if their type is not contained in the filter - list. - @param formatSequences flag indicating, that sequence or dictionary variables - should be formatted. If it is 0 (or false), just the number of items contained - in these variables is returned. (boolean) - @return A tuple consisting of a list of formatted variables. Each variable - entry is a tuple of three elements, the variable name, its type and - value. + Variables are only added to the list, if their name do not match + any of the filter expressions. + @param filter the indices of variable types to be filtered. Variables + are only added to the list, if their type is not contained in the + filter list. + @param formatSequences flag indicating, that sequence or dictionary + variables should be formatted. If it is 0 (or false), just the + number of items contained in these variables is returned. (boolean) + @return A tuple consisting of a list of formatted variables. Each + variable entry is a tuple of three elements, the variable name, + its type and value. """ varlist = [] if scope: @@ -1703,10 +1739,12 @@ continue except ValueError: if valtype == "classobj": - if ConfigVarTypeStrings.index('instance') in filter: + if ConfigVarTypeStrings.index( + 'instance') in filter: continue elif valtype == "sip.methoddescriptor": - if ConfigVarTypeStrings.index('instance method') in filter: + if ConfigVarTypeStrings.index( + 'instance method') in filter: continue elif valtype == "sip.enumtype": if ConfigVarTypeStrings.index('class') in filter: @@ -1799,9 +1837,12 @@ @param host hostname of the debug server (string) @param port portnumber of the debug server (int) @param enableTrace flag to enable the tracing function (boolean) - @param exceptions flag to enable exception reporting of the IDE (boolean) - @param tracePython flag to enable tracing into the Python library (boolean) - @param redirect flag indicating redirection of stdin, stdout and stderr (boolean) + @param exceptions flag to enable exception reporting of the IDE + (boolean) + @param tracePython flag to enable tracing into the Python library + (boolean) + @param redirect flag indicating redirection of stdin, stdout and + stderr (boolean) """ global debugClient if host is None: @@ -1821,7 +1862,8 @@ if self.running: self.__setCoding(self.running) self.passive = 1 - self.write("%s%s|%d\n" % (DebugProtocol.PassiveStartup, self.running, exceptions)) + self.write("%s%s|%d\n" % ( + DebugProtocol.PassiveStartup, self.running, exceptions)) self.__interact() # setup the debugger variables @@ -1852,9 +1894,12 @@ @param wd working directory for the program execution (string) @param host hostname of the debug server (string) @param port portnumber of the debug server (int) - @param exceptions flag to enable exception reporting of the IDE (boolean) - @param tracePython flag to enable tracing into the Python library (boolean) - @param redirect flag indicating redirection of stdin, stdout and stderr (boolean) + @param exceptions flag to enable exception reporting of the IDE + (boolean) + @param tracePython flag to enable tracing into the Python library + (boolean) + @param redirect flag indicating redirection of stdin, stdout and + stderr (boolean) """ if host is None: host = os.getenv('ERICHOST', 'localhost') @@ -1880,7 +1925,8 @@ self.debugging = 1 self.passive = 1 - self.write("%s%s|%d\n" % (DebugProtocol.PassiveStartup, self.running, exceptions)) + self.write("%s%s|%d\n" % ( + DebugProtocol.PassiveStartup, self.running, exceptions)) self.__interact() self.attachThread(mainThread=1) @@ -1893,8 +1939,8 @@ # This will eventually enter a local event loop. # Note the use of backquotes to cause a repr of self.running. The # need for this is on Windows os where backslash is the path separator. - # They will get inadvertantly stripped away during the eval causing IOErrors - # if self.running is passed as a normal str. + # They will get inadvertantly stripped away during the eval causing + # IOErrors if self.running is passed as a normal str. self.debugMod.__dict__['__file__'] = self.running sys.modules['__main__'] = self.debugMod res = self.mainThread.run('execfile(' + repr(self.running) + ')', @@ -1930,7 +1976,8 @@ family = socket.AF_INET else: family = socket.AF_INET6 - return socket.getaddrinfo(host, None, family, socket.SOCK_STREAM)[0][4][0] + return socket.getaddrinfo(host, None, family, + socket.SOCK_STREAM)[0][4][0] def main(self): """ @@ -1988,7 +2035,8 @@ if not self.noencoding: self.__coding = self.defaultCoding self.startProgInDebugger(args, wd, host, port, - exceptions=exceptions, tracePython=tracePython, + exceptions=exceptions, + tracePython=tracePython, redirect=redirect) else: if sys.argv[1] == '--no-encoding': @@ -2052,7 +2100,8 @@ def close(self, fd): """ - Private method implementing a close method as a replacement for os.close(). + Private method implementing a close method as a replacement for + os.close(). It prevents the debugger connections from being closed. @@ -2072,7 +2121,8 @@ @param firstEntry entry to be put first in sys.path (string) @return path list for use as sys.path (list of strings) """ - sysPath = [path for path in os.environ.get("PYTHONPATH", "").split(os.pathsep) + sysPath = [path for path in os.environ.get("PYTHONPATH", "") + .split(os.pathsep) if path not in sys.path] + sys.path[:] if "" in sysPath: sysPath.remove("")
--- a/DebugClients/Python/DebugClientThreads.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python/DebugClientThreads.py Sun Oct 06 18:02:21 2013 +0200 @@ -35,7 +35,8 @@ @return The identifier of the created thread """ if DebugClientBase.DebugClientInstance is not None: - return DebugClientBase.DebugClientInstance.attachThread(target, args, kwargs) + return DebugClientBase.DebugClientInstance.attachThread( + target, args, kwargs) else: return _original_start_thread(target, args, kwargs) @@ -66,7 +67,8 @@ # protection lock for synchronization self.clientLock = RLock() - # the "current" thread, basically the thread we are at a breakpoint for. + # the "current" thread, basically the thread we are at a breakpoint + # for. self.currentThread = None # special objects representing the main scripts thread and frame @@ -82,7 +84,8 @@ If mainThread is non-zero, then we are attaching to the already started mainthread of the app and the rest of the args are ignored. - @param target the start function of the target thread (i.e. the user code) + @param target the start function of the target thread (i.e. the + user code) @param args arguments to pass to target @param kwargs keyword arguments to pass to target @param mainThread non-zero, if we are attaching to the already
--- a/DebugClients/Python/FlexCompleter.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python/FlexCompleter.py Sun Oct 06 18:02:21 2013 +0200 @@ -24,12 +24,12 @@ selectable namespace. The problem with rlcompleter is that it's hardwired to work with - __main__.__dict__, and in some cases one may have 'sandboxed' namespaces. So - this class is a ripoff of rlcompleter, with the namespace to work in as an - optional parameter. + __main__.__dict__, and in some cases one may have 'sandboxed' namespaces. + So this class is a ripoff of rlcompleter, with the namespace to work in as + an optional parameter. - This class can be used just like rlcompleter, but the Completer class now has - a constructor with the optional 'namespace' parameter. + This class can be used just like rlcompleter, but the Completer class now + has a constructor with the optional 'namespace' parameter. A patch has been submitted to Python@sourceforge for these changes to go in the standard Python distribution. @@ -177,7 +177,9 @@ __builtin__.__dict__.keys(), self.namespace.keys()]: for word in list: - if word[:n] == text and word != "__builtins__" and not word in matches: + if word[:n] == text and \ + word != "__builtins__" and \ + not word in matches: matches.append(word) return matches
--- a/DebugClients/Python/PyProfile.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python/PyProfile.py Sun Oct 06 18:02:21 2013 +0200 @@ -162,7 +162,8 @@ "exception": profile.Profile.trace_dispatch_exception, "return": profile.Profile.trace_dispatch_return, "c_call": profile.Profile.trace_dispatch_c_call, - "c_exception": profile.Profile.trace_dispatch_return, # the C function returned + "c_exception": profile.Profile.trace_dispatch_return, + # the C function returned "c_return": profile.Profile.trace_dispatch_return, }
--- a/DebugClients/Python/eric5dbgstub.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python/eric5dbgstub.py Sun Oct 06 18:02:21 2013 +0200 @@ -78,9 +78,12 @@ Module function used to start the remote debugger. @keyparam enableTrace flag to enable the tracing function (boolean) - @keyparam exceptions flag to enable exception reporting of the IDE (boolean) - @keyparam tracePython flag to enable tracing into the Python library (boolean) - @keyparam redirect flag indicating redirection of stdin, stdout and stderr (boolean) + @keyparam exceptions flag to enable exception reporting of the IDE + (boolean) + @keyparam tracePython flag to enable tracing into the Python library + (boolean) + @keyparam redirect flag indicating redirection of stdin, stdout and + stderr (boolean) """ global debugger if debugger:
--- a/DebugClients/Python3/AsyncFile.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python3/AsyncFile.py Sun Oct 06 18:02:21 2013 +0200 @@ -4,7 +4,8 @@ # """ -Module implementing an asynchronous file like socket interface for the debugger. +Module implementing an asynchronous file like socket interface for the +debugger. """ import socket @@ -101,7 +102,8 @@ """ Public method to close the file. - @param closeit flag to indicate a close ordered by the debugger code (boolean) + @param closeit flag to indicate a close ordered by the debugger code + (boolean) """ if closeit and not self.closed: self.flush() @@ -301,10 +303,11 @@ if not self.wpending: self.wpending = s elif len(self.wpending) + len(s) > self.maxbuffersize: - # flush wpending so that different string types are not concatenated + # flush wpending so that different string types are not + # concatenated while self.wpending: - # if we have a persistent error in sending the data, an exception - # will be raised in __nWrite + # if we have a persistent error in sending the data, an + # exception will be raised in __nWrite self.flush() tries += 1 if tries > self.maxtries:
--- a/DebugClients/Python3/DCTestResult.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python3/DCTestResult.py Sun Oct 06 18:02:21 2013 +0200 @@ -108,7 +108,8 @@ self.parent.write('{0}\n'.format(ResponseUTStopTest)) # ensure that pending input is processed - rrdy, wrdy, xrdy = select.select([self.parent.readstream], [], [], 0.01) + rrdy, wrdy, xrdy = select.select( + [self.parent.readstream], [], [], 0.01) if self.parent.readstream in rrdy: self.parent.readReady(self.parent.readstream.fileno())
--- a/DebugClients/Python3/DebugBase.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python3/DebugBase.py Sun Oct 06 18:02:21 2013 +0200 @@ -13,8 +13,8 @@ import atexit import inspect -from DebugProtocol import ResponseClearWatch, ResponseClearBreak, ResponseLine, \ - ResponseSyntax, ResponseException, CallTrace +from DebugProtocol import ResponseClearWatch, ResponseClearBreak, \ + ResponseLine, ResponseSyntax, ResponseException, CallTrace gRecursionLimit = 64 @@ -405,8 +405,8 @@ Private method to determine, if a watch expression is effective. @param frame the current execution frame - @return tuple of watch expression and a flag to indicate, that a temporary - watch expression may be deleted (bdb.Breakpoint, boolean) + @return tuple of watch expression and a flag to indicate, that a + temporary watch expression may be deleted (bdb.Breakpoint, boolean) """ possibles = bdb.Breakpoint.bplist["Watch", 0] for i in range(0, len(possibles)): @@ -414,7 +414,8 @@ if not b.enabled: continue if not b.cond: - # watch expression without expression shouldn't occur, just ignore it + # watch expression without expression shouldn't occur, + # just ignore it continue try: val = eval(b.condition, frame.f_globals, frame.f_locals) @@ -471,7 +472,8 @@ lineno = frame.f_lineno if lineno not in self.breaks[filename]: # The line itself has no breakpoint, but maybe the line is the - # first line of a function with breakpoint set by function name. + # first line of a function with breakpoint set by function + # name. lineno = frame.f_code.co_firstlineno if lineno in self.breaks[filename]: # flag says ok to delete temp. bp @@ -509,7 +511,8 @@ def get_break(self, filename, lineno): """ - Reimplemented from bdb.py to get the first breakpoint of a particular line. + Reimplemented from bdb.py to get the first breakpoint of a particular + line. Because eric5 supports only one breakpoint per line, this overwritten method will return this one and only breakpoint. @@ -554,8 +557,9 @@ if ffunc and not ffunc.startswith("<"): argInfo = inspect.getargvalues(fr) - fargs = inspect.formatargvalues(argInfo.args, argInfo.varargs, - argInfo.keywords, argInfo.locals) + fargs = inspect.formatargvalues( + argInfo.args, argInfo.varargs, + argInfo.keywords, argInfo.locals) else: fargs = "" @@ -611,8 +615,9 @@ if ffunc and not ffunc.startswith("<"): argInfo = inspect.getargvalues(fr) - fargs = inspect.formatargvalues(argInfo.args, argInfo.varargs, - argInfo.keywords, argInfo.locals) + fargs = inspect.formatargvalues( + argInfo.args, argInfo.varargs, + argInfo.keywords, argInfo.locals) else: fargs = "" @@ -655,7 +660,8 @@ if exctype in [SyntaxError, IndentationError]: try: - message, (filename, linenr, charnr, text) = excval[0], excval[1] + message, (filename, linenr, charnr, text) = \ + excval[0], excval[1] except ValueError: exclist = [] realSyntaxError = True @@ -664,7 +670,8 @@ realSyntaxError = os.path.exists(filename) if realSyntaxError: - self._dbgClient.write("{0}{1}\n".format(ResponseSyntax, str(exclist))) + self._dbgClient.write("{0}{1}\n".format( + ResponseSyntax, str(exclist))) self._dbgClient.eventLoop() return @@ -705,14 +712,16 @@ if ffunc and not ffunc.startswith("<"): argInfo = inspect.getargvalues(fr) - fargs = inspect.formatargvalues(argInfo.args, argInfo.varargs, - argInfo.keywords, argInfo.locals) + fargs = inspect.formatargvalues( + argInfo.args, argInfo.varargs, + argInfo.keywords, argInfo.locals) else: fargs = "" exclist.append([filename, linenr, ffunc, fargs]) - self._dbgClient.write("{0}{1}\n".format(ResponseException, str(exclist))) + self._dbgClient.write("{0}{1}\n".format( + ResponseException, str(exclist))) if exctb is None: return
--- a/DebugClients/Python3/DebugClientBase.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python3/DebugClientBase.py Sun Oct 06 18:02:21 2013 +0200 @@ -29,7 +29,7 @@ DebugClientInstance = None -################################################################################ +############################################################################### def DebugClientInput(prompt="", echo=True): @@ -56,7 +56,7 @@ DebugClientOrigInput = __main__.__builtins__.__dict__['input'] __main__.__builtins__.__dict__['input'] = DebugClientInput -################################################################################ +############################################################################### def DebugClientFork(): @@ -75,7 +75,7 @@ DebugClientOrigFork = os.fork os.fork = DebugClientFork -################################################################################ +############################################################################### def DebugClientClose(fd): @@ -94,7 +94,7 @@ DebugClientOrigClose = os.close os.close = DebugClientClose -################################################################################ +############################################################################### def DebugClientSetRecursionLimit(limit): @@ -113,15 +113,15 @@ sys.setrecursionlimit = DebugClientSetRecursionLimit DebugClientSetRecursionLimit(sys.getrecursionlimit()) -################################################################################ +############################################################################### class DebugClientBase(object): """ Class implementing the client side of the debugger. - It provides access to the Python interpeter from a debugger running in another - process whether or not the Qt event loop is running. + It provides access to the Python interpeter from a debugger running in + another process whether or not the Qt event loop is running. The protocol between the debugger and the client assumes that there will be a single source of debugger commands and a single source of Python @@ -134,12 +134,11 @@ See DebugProtocol.py for a listing of valid protocol tokens. A Python statement consists of the statement to execute, followed (in a - separate line) by >OK?<. If the statement was incomplete then the response - is >Continue<. If there was an exception then the response is - >Exception<. - Otherwise the response is >OK<. The reason for the >OK?< part is to - provide a sentinal (ie. the responding >OK<) after any possible output as a - result of executing the command. + separate line) by >OK?<. If the statement was incomplete then the + response is >Continue<. If there was an exception then the response + is >Exception<. Otherwise the response is >OK<. The reason + for the >OK?< part is to provide a sentinal (ie. the responding + >OK<) after any possible output as a result of executing the command. The client may send any other lines at any other time which should be interpreted as program output. @@ -148,8 +147,8 @@ The client may close the session at any time as a result of the script being debugged closing or crashing. - <b>Note</b>: This class is meant to be subclassed by individual DebugClient classes. - Do not instantiate it directly. + <b>Note</b>: This class is meant to be subclassed by individual + DebugClient classes. Do not instantiate it directly. """ clientCapabilities = DebugClientCapabilities.HasAll @@ -167,7 +166,8 @@ # dictionary of all threads running self.threads = {} - # the "current" thread, basically the thread we are at a breakpoint for. + # the "current" thread, basically the thread we are at a breakpoint + # for. self.currentThread = self # special objects representing the main scripts thread and frame @@ -256,14 +256,16 @@ return self.__coding = default - def attachThread(self, target=None, args=None, kwargs=None, mainThread=False): + def attachThread(self, target=None, args=None, kwargs=None, + mainThread=False): """ Public method to setup a thread for DebugClient to debug. If mainThread is non-zero, then we are attaching to the already started mainthread of the app and the rest of the args are ignored. - @param target the start function of the target thread (i.e. the user code) + @param target the start function of the target thread (i.e. the + user code) @param args arguments to pass to target @param kwargs keyword arguments to pass to target @param mainThread True, if we are attaching to the already @@ -277,7 +279,8 @@ Public method to send the list of threads. """ threadList = [] - if self.threads and self.currentThread: # indication for the threaded debugger + if self.threads and self.currentThread: + # indication for the threaded debugger currentId = self.currentThread.get_ident() for t in self.threads.values(): d = {} @@ -304,7 +307,8 @@ @param echo Flag indicating echoing of the input (boolean) @return the entered string """ - self.write("{0}{1!r}\n".format(DebugProtocol.ResponseRaw, (prompt, echo))) + self.write("{0}{1!r}\n".format( + DebugProtocol.ResponseRaw, (prompt, echo))) self.inRawMode = True self.eventLoop(True) return self.rawLine @@ -319,7 +323,8 @@ def sessionClose(self, exit=True): """ - Public method to close the session with the debugger and optionally terminate. + Public method to close the session with the debugger and optionally + terminate. @param exit flag indicating to terminate (boolean) """ @@ -359,13 +364,15 @@ except SyntaxError: exctype, excval, exctb = sys.exc_info() try: - message, (filename, linenr, charnr, text) = excval[0], excval[1] + message, (filename, linenr, charnr, text) = \ + excval[0], excval[1] except ValueError: exclist = [] else: exclist = [message, [filename, linenr, charnr]] - self.write("{0}{1}\n".format(DebugProtocol.ResponseSyntax, str(exclist))) + self.write("{0}{1}\n".format( + DebugProtocol.ResponseSyntax, str(exclist))) return None return code @@ -374,8 +381,8 @@ """ Public method to handle the receipt of a complete line. - It first looks for a valid protocol token at the start of the line. Thereafter - it trys to execute the lines accumulated so far. + It first looks for a valid protocol token at the start of the line. + Thereafter it trys to execute the lines accumulated so far. @param line the received line """ @@ -412,7 +419,8 @@ self.setCurrentThread(tid) self.write(DebugProtocol.ResponseThreadSet + '\n') stack = self.currentThread.getStack() - self.write('{0}{1!r}\n'.format(DebugProtocol.ResponseStack, stack)) + self.write('{0}{1!r}\n'.format( + DebugProtocol.ResponseStack, stack)) return if cmd == DebugProtocol.RequestStep: @@ -457,7 +465,8 @@ if self.debugging: self.callTraceEnabled = callTraceEnabled else: - self.__newCallTraceEnabled = callTraceEnabled # remember for later + self.__newCallTraceEnabled = callTraceEnabled + # remember for later return if cmd == DebugProtocol.RequestEnv: @@ -498,16 +507,18 @@ # we report on all unhandled exceptions sys.excepthook = self.__unhandled_exception - # clear all old breakpoints, they'll get set after we have started + # clear all old breakpoints, they'll get set after we have + # started self.mainThread.clear_all_breaks() self.mainThread.tracePython = tracePython # This will eventually enter a local event loop. - # Note the use of backquotes to cause a repr of self.running. The - # need for this is on Windows os where backslash is the path separator. - # They will get inadvertantly stripped away during the eval causing - # IOErrors, if self.running is passed as a normal str. + # Note the use of backquotes to cause a repr of self.running. + # The need for this is on Windows os where backslash is the + # path separator. They will get inadvertantly stripped away + # during the eval causing IOErrors, if self.running is passed + # as a normal str. self.debugMod.__dict__['__file__'] = self.running sys.modules['__main__'] = self.debugMod code = self.__compileFileSource(self.running) @@ -620,7 +631,8 @@ # generate a coverage object self.cover = coverage(auto_data=True, - data_file="{0}.coverage".format(os.path.splitext(sys.argv[0])[0])) + data_file="{0}.coverage".format( + os.path.splitext(sys.argv[0])[0])) self.cover.use_cache(True) if int(erase): @@ -668,7 +680,8 @@ compile(cond, '<string>', 'eval') except SyntaxError: self.write('{0}{1},{2:d}\n'.format( - DebugProtocol.ResponseBPConditionError, fn, line)) + DebugProtocol.ResponseBPConditionError, + fn, line)) return self.mainThread.set_break(fn, line, temporary, cond) else: @@ -746,8 +759,10 @@ if cmd == DebugProtocol.RequestEval: try: - value = eval(arg, self.currentThread.getCurrentFrame().f_globals, - self.currentThread.getCurrentFrameLocals()) + value = eval( + arg, + self.currentThread.getCurrentFrame().f_globals, + self.currentThread.getCurrentFrameLocals()) except: # Report the exception and the traceback try: @@ -852,7 +867,8 @@ .loadTestsFromModule(utModule) except: exc_type, exc_value, exc_tb = sys.exc_info() - self.write('{0}{1}\n'.format(DebugProtocol.ResponseUTPrepared, + self.write('{0}{1}\n'.format( + DebugProtocol.ResponseUTPrepared, str((0, str(exc_type), str(exc_value))))) self.__exceptionRaised() return @@ -861,7 +877,8 @@ if int(cov): from coverage import coverage self.cover = coverage(auto_data=True, - data_file="{0}.coverage".format(os.path.splitext(covname)[0])) + data_file="{0}.coverage".format( + os.path.splitext(covname)[0])) self.cover.use_cache(True) if int(erase): self.cover.erase() @@ -916,7 +933,8 @@ except (OverflowError, SyntaxError, ValueError): # Report the exception sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info() - for l in traceback.format_exception_only(sys.last_type, sys.last_value): + for l in traceback.format_exception_only( + sys.last_type, sys.last_value): self.write(l) self.buffer = '' else: @@ -947,7 +965,8 @@ cf = cf.f_back frmnr -= 1 _globals = cf.f_globals - _locals = self.currentThread.getCurrentFrameLocals() + _locals = \ + self.currentThread.getCurrentFrameLocals() # reset sys.stdout to our redirector (unconditionally) if "sys" in _globals: __stdout = _globals["sys"].stdout @@ -975,8 +994,8 @@ list = traceback.format_list(tblist) if list: list.insert(0, "Traceback (innermost last):\n") - list[len(list):] = \ - traceback.format_exception_only(exc_type, exc_value) + list[len(list):] = traceback.format_exception_only( + exc_type, exc_value) finally: tblist = exc_tb = None @@ -997,7 +1016,8 @@ pass return self.clientCapabilities except ImportError: - return self.clientCapabilities & ~DebugClientCapabilities.HasProfiler + return (self.clientCapabilities & + ~DebugClientCapabilities.HasProfiler) def write(self, s): """ @@ -1105,10 +1125,12 @@ being debugged redirects them itself. @param port the port number to connect to (int) - @param remoteAddress the network address of the debug server host (string) - @param redirect flag indicating redirection of stdin, stdout and stderr (boolean) + @param remoteAddress the network address of the debug server host + (string) + @param redirect flag indicating redirection of stdin, stdout and + stderr (boolean) """ - if remoteAddress is None: # default: 127.0.0.1 + if remoteAddress is None: # default: 127.0.0.1 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((DebugProtocol.DebugAddress, port)) else: @@ -1116,13 +1138,13 @@ remoteAddress, index = remoteAddress.split("@@i") else: index = 0 - if ":" in remoteAddress: # IPv6 + if ":" in remoteAddress: # IPv6 sockaddr = socket.getaddrinfo( remoteAddress, port, 0, 0, socket.SOL_TCP)[0][-1] sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) sockaddr = sockaddr[:-1] + (int(index),) sock.connect(sockaddr) - else: # IPv4 + else: # IPv4 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((remoteAddress, port)) @@ -1195,7 +1217,8 @@ Public method to check if a file should be skipped. @param fn filename to be checked - @return non-zero if fn represents a file we are 'skipping', zero otherwise. + @return non-zero if fn represents a file we are 'skipping', + zero otherwise. """ if self.mainThread.tracePython: # trace into Python library return False @@ -1247,9 +1270,11 @@ """ Private method to return the variables of a frame to the debug server. - @param frmnr distance of frame reported on. 0 is the current frame (int) + @param frmnr distance of frame reported on. 0 is the current frame + (int) @param scope 1 to report global variables, 0 for local variables (int) - @param filter the indices of variable types to be filtered (list of int) + @param filter the indices of variable types to be filtered + (list of int) """ if self.currentThread is None: return @@ -1282,16 +1307,20 @@ vlist = self.__formatVariablesList(keylist, dict, scope, filter) varlist.extend(vlist) - self.write('{0}{1}\n'.format(DebugProtocol.ResponseVariables, str(varlist))) + self.write('{0}{1}\n'.format( + DebugProtocol.ResponseVariables, str(varlist))) def __dumpVariable(self, var, frmnr, scope, filter): """ Private method to return the variables of a frame to the debug server. - @param var list encoded name of the requested variable (list of strings) - @param frmnr distance of frame reported on. 0 is the current frame (int) + @param var list encoded name of the requested variable + (list of strings) + @param frmnr distance of frame reported on. 0 is the current frame + (int) @param scope 1 to report global variables, 0 for local variables (int) - @param filter the indices of variable types to be filtered (list of int) + @param filter the indices of variable types to be filtered + (list of int) """ if self.currentThread is None: return @@ -1354,14 +1383,17 @@ if oaccess: access = oaccess else: - access = '{0!s}[{1!s}]'.format(access, var[i - 1]) + access = '{0!s}[{1!s}]'.format( + access, var[i - 1]) dict = odict else: if oaccess: - access = '{0!s}[{1!s}]'.format(oaccess, var[i][:-2]) + access = '{0!s}[{1!s}]'.format( + oaccess, var[i][:-2]) oaccess = '' else: - access = '{0!s}[{1!s}]'.format(access, var[i][:-2]) + access = '{0!s}[{1!s}]'.format( + access, var[i][:-2]) if var[i][-2:] == "{}": isDict = True break @@ -1374,14 +1406,17 @@ access = '["{0!s}"]'.format(var[i][:-2]) else: if var[i][:-2] == '...': - access = '{0!s}[{1!s}]'.format(access, var[i - 1]) + access = '{0!s}[{1!s}]'.format( + access, var[i - 1]) dict = odict else: if oaccess: - access = '{0!s}[{1!s}]'.format(oaccess, var[i][:-2]) + access = '{0!s}[{1!s}]'.format( + oaccess, var[i][:-2]) oaccess = '' else: - access = '{0!s}[{1!s}]'.format(access, var[i][:-2]) + access = '{0!s}[{1!s}]'.format( + access, var[i][:-2]) else: if access: if oaccess: @@ -1422,12 +1457,14 @@ for v in loc["slv"]: try: loc["v"] = v - exec('cdict[v] = dict{0!s}.{1!s}'.format(access, v), + exec('cdict[v] = dict{0!s}.{1!s}'.format( + access, v), globals, loc) except: pass ndict.update(loc["cdict"]) - exec('obj = dict{0!s}'.format(access), globals(), loc) + exec('obj = dict{0!s}'.format(access), + globals(), loc) obj = loc["obj"] access = "" if "PyQt4." in str(type(obj)): @@ -1450,11 +1487,13 @@ pass try: slv = dict[var[i]].__slots__ - loc = {"cdict": {}, "dict": dict, "var": var, "i": i} + loc = {"cdict": {}, "dict": dict, + "var": var, "i": i} for v in slv: try: loc["v"] = v - exec('cdict[v] = dict[var[i]].{0!s}'.format(v), + exec('cdict[v] = dict[var[i]].{0!s}' + .format(v), globals(), loc) except: pass @@ -1481,7 +1520,8 @@ # this has to be in line with VariablesViewer.indicators elif rvar and rvar[0][-2:] in ["[]", "()", "{}"]: loc = {"udict": udict} - exec('qvar = udict["{0!s}"][{1!s}]'.format(rvar[0][:-2], rvar[1]), + exec('qvar = udict["{0!s}"][{1!s}]'.format(rvar[0][:-2], + rvar[1]), globals(), loc) qvar = loc["qvar"] else: @@ -1501,8 +1541,8 @@ # this has to be in line with VariablesViewer.indicators elif rvar and rvar[0][-2:] in ["[]", "()", "{}"]: loc = {"udict": udict} - exec('qvar = udict["{0!s}"][{1!s}]'.format(rvar[0][:-2], rvar[1]), - globals(), loc) + exec('qvar = udict["{0!s}"][{1!s}]'.format( + rvar[0][:-2], rvar[1]), globals(), loc) qvar = loc["qvar"] else: qvar = udict[var[-1]] @@ -1520,7 +1560,8 @@ # treatment for sequences and dictionaries if access: loc = {"dict": dict} - exec("dict = dict{0!s}".format(access), globals(), loc) + exec("dict = dict{0!s}".format(access), globals(), + loc) dict = loc["dict"] else: dict = dict[dictkeys[0]] @@ -1528,22 +1569,26 @@ dictkeys = dict.keys() else: dictkeys = range(len(dict)) - vlist = self.__formatVariablesList(dictkeys, dict, scope, filter, - formatSequences) + vlist = self.__formatVariablesList( + dictkeys, dict, scope, filter, formatSequences) varlist.extend(vlist) if obj is not None and not formatSequences: try: if repr(obj).startswith('{'): - varlist.append(('...', 'dict', "{0:d}".format(len(obj.keys())))) + varlist.append( + ('...', 'dict', "{0:d}".format(len(obj.keys())))) elif repr(obj).startswith('['): - varlist.append(('...', 'list', "{0:d}".format(len(obj)))) + varlist.append( + ('...', 'list', "{0:d}".format(len(obj)))) elif repr(obj).startswith('('): - varlist.append(('...', 'tuple', "{0:d}".format(len(obj)))) + varlist.append( + ('...', 'tuple', "{0:d}".format(len(obj)))) except: pass - self.write('{0}{1}\n'.format(DebugProtocol.ResponseVariable, str(varlist))) + self.write('{0}{1}\n'.format( + DebugProtocol.ResponseVariable, str(varlist))) def __formatQt4Variable(self, value, vtype): """ @@ -1561,9 +1606,12 @@ varlist.append(("", "QChar", "{0}".format(chr(value.unicode())))) varlist.append(("", "int", "{0:d}".format(value.unicode()))) elif qttype == 'QByteArray': - varlist.append(("bytes", "QByteArray", "{0}".format(bytes(value))[2:-1])) - varlist.append(("hex", "QByteArray", "{0}".format(value.toHex())[2:-1])) - varlist.append(("base64", "QByteArray", "{0}".format(value.toBase64())[2:-1])) + varlist.append( + ("bytes", "QByteArray", "{0}".format(bytes(value))[2:-1])) + varlist.append( + ("hex", "QByteArray", "{0}".format(value.toHex())[2:-1])) + varlist.append( + ("base64", "QByteArray", "{0}".format(value.toBase64())[2:-1])) varlist.append(("percent encoding", "QByteArray", "{0}".format(value.toPercentEncoding())[2:-1])) elif qttype == 'QPoint': @@ -1591,14 +1639,17 @@ elif qttype == 'QColor': varlist.append(("name", "str", "{0}".format(value.name()))) r, g, b, a = value.getRgb() - varlist.append(("rgb", "int", - "{0:d}, {1:d}, {2:d}, {3:d}".format(r, g, b, a))) + varlist.append( + ("rgb", "int", + "{0:d}, {1:d}, {2:d}, {3:d}".format(r, g, b, a))) h, s, v, a = value.getHsv() - varlist.append(("hsv", "int", - "{0:d}, {1:d}, {2:d}, {3:d}".format(h, s, v, a))) + varlist.append( + ("hsv", "int", + "{0:d}, {1:d}, {2:d}, {3:d}".format(h, s, v, a))) c, m, y, k, a = value.getCmyk() - varlist.append(("cmyk", "int", - "{0:d}, {1:d}, {2:d}, {3:d}, {4:d}".format(c, m, y, k, a))) + varlist.append( + ("cmyk", "int", + "{0:d}, {1:d}, {2:d}, {3:d}, {4:d}".format(c, m, y, k, a))) elif qttype == 'QDate': varlist.append(("", "QDate", "{0}".format(value.toString()))) elif qttype == 'QTime': @@ -1615,7 +1666,8 @@ varlist.append(("fileName", "str", "{0}".format(value.fileName()))) elif qttype == 'QFont': varlist.append(("family", "str", "{0}".format(value.family()))) - varlist.append(("pointSize", "int", "{0:d}".format(value.pointSize()))) + varlist.append( + ("pointSize", "int", "{0:d}".format(value.pointSize()))) varlist.append(("weight", "int", "{0:d}".format(value.weight()))) varlist.append(("bold", "bool", "{0}".format(value.bold()))) varlist.append(("italic", "bool", "{0}".format(value.italic()))) @@ -1632,7 +1684,8 @@ if value.isValid(): varlist.append(("row", "int", "{0}".format(value.row()))) varlist.append(("column", "int", "{0}".format(value.column()))) - varlist.append(("internalId", "int", "{0}".format(value.internalId()))) + varlist.append( + ("internalId", "int", "{0}".format(value.internalId()))) varlist.append(("internalPointer", "void *", "{0}".format(value.internalPointer()))) elif qttype == 'QRegExp': @@ -1642,11 +1695,14 @@ elif qttype == 'QAction': varlist.append(("name", "str", "{0}".format(value.objectName()))) varlist.append(("text", "str", "{0}".format(value.text()))) - varlist.append(("icon text", "str", "{0}".format(value.iconText()))) + varlist.append( + ("icon text", "str", "{0}".format(value.iconText()))) varlist.append(("tooltip", "str", "{0}".format(value.toolTip()))) - varlist.append(("whatsthis", "str", "{0}".format(value.whatsThis()))) - varlist.append(("shortcut", "str", - "{0}".format(value.shortcut().toString()))) + varlist.append( + ("whatsthis", "str", "{0}".format(value.whatsThis()))) + varlist.append( + ("shortcut", "str", + "{0}".format(value.shortcut().toString()))) elif qttype == 'QKeySequence': varlist.append(("value", "", "{0}".format(value.toString()))) @@ -1668,7 +1724,8 @@ # Networking stuff elif qttype == 'QHostAddress': - varlist.append(("address", "QHostAddress", "{0}".format(value.toString()))) + varlist.append( + ("address", "QHostAddress", "{0}".format(value.toString()))) return varlist @@ -1679,24 +1736,25 @@ The dictionary passed in to it is scanned. Variables are only added to the list, if their type is not contained - in the filter list and their name doesn't match any of the filter expressions. - The formated variables list (a list of tuples of 3 values) is returned. + in the filter list and their name doesn't match any of the filter + expressions. The formated variables list (a list of tuples of 3 + values) is returned. @param keylist keys of the dictionary @param dict the dictionary to be scanned @param scope 1 to filter using the globals filter, 0 using the locals filter (int). - Variables are only added to the list, if their name do not match any of the - filter expressions. - @param filter the indices of variable types to be filtered. Variables are - only added to the list, if their type is not contained in the filter - list. - @param formatSequences flag indicating, that sequence or dictionary variables - should be formatted. If it is 0 (or false), just the number of items contained - in these variables is returned. (boolean) - @return A tuple consisting of a list of formatted variables. Each variable - entry is a tuple of three elements, the variable name, its type and - value. + Variables are only added to the list, if their name do not match + any of the filter expressions. + @param filter the indices of variable types to be filtered. Variables + are only added to the list, if their type is not contained in the + filter list. + @param formatSequences flag indicating, that sequence or dictionary + variables should be formatted. If it is 0 (or false), just the + number of items contained in these variables is returned. (boolean) + @return A tuple consisting of a list of formatted variables. Each + variable entry is a tuple of three elements, the variable name, + its type and value. """ varlist = [] if scope: @@ -1731,7 +1789,8 @@ if ConfigVarTypeStrings.index('instance') in filter: continue elif valtype == "sip.methoddescriptor": - if ConfigVarTypeStrings.index('instance method') in filter: + if ConfigVarTypeStrings.index( + 'instance method') in filter: continue elif valtype == "sip.enumtype": if ConfigVarTypeStrings.index('class') in filter: @@ -1743,10 +1802,12 @@ continue except ValueError: if valtype == "classobj": - if ConfigVarTypeStrings.index('instance') in filter: + if ConfigVarTypeStrings.index( + 'instance') in filter: continue elif valtype == "sip.methoddescriptor": - if ConfigVarTypeStrings.index('instance method') in filter: + if ConfigVarTypeStrings.index( + 'instance method') in filter: continue elif valtype == "sip.enumtype": if ConfigVarTypeStrings.index('class') in filter: @@ -1831,7 +1892,8 @@ str(completions), text)) def startDebugger(self, filename=None, host=None, port=None, - enableTrace=True, exceptions=True, tracePython=False, redirect=True): + enableTrace=True, exceptions=True, tracePython=False, + redirect=True): """ Public method used to start the remote debugger. @@ -1839,9 +1901,12 @@ @param host hostname of the debug server (string) @param port portnumber of the debug server (int) @param enableTrace flag to enable the tracing function (boolean) - @param exceptions flag to enable exception reporting of the IDE (boolean) - @param tracePython flag to enable tracing into the Python library (boolean) - @param redirect flag indicating redirection of stdin, stdout and stderr (boolean) + @param exceptions flag to enable exception reporting of the IDE + (boolean) + @param tracePython flag to enable tracing into the Python library + (boolean) + @param redirect flag indicating redirection of stdin, stdout and + stderr (boolean) """ global debugClient if host is None: @@ -1893,9 +1958,12 @@ @param wd working directory for the program execution (string) @param host hostname of the debug server (string) @param port portnumber of the debug server (int) - @param exceptions flag to enable exception reporting of the IDE (boolean) - @param tracePython flag to enable tracing into the Python library (boolean) - @param redirect flag indicating redirection of stdin, stdout and stderr (boolean) + @param exceptions flag to enable exception reporting of the IDE + (boolean) + @param tracePython flag to enable tracing into the Python library + (boolean) + @param redirect flag indicating redirection of stdin, stdout and + stderr (boolean) """ if host is None: host = os.getenv('ERICHOST', 'localhost') @@ -1935,12 +2003,13 @@ # This will eventually enter a local event loop. # Note the use of backquotes to cause a repr of self.running. The # need for this is on Windows os where backslash is the path separator. - # They will get inadvertantly stripped away during the eval causing IOErrors - # if self.running is passed as a normal str. + # They will get inadvertantly stripped away during the eval causing + # IOErrors if self.running is passed as a normal str. self.debugMod.__dict__['__file__'] = self.running sys.modules['__main__'] = self.debugMod - res = self.mainThread.run('exec(open(' + repr(self.running) + ').read())', - self.debugMod.__dict__) + res = self.mainThread.run( + 'exec(open(' + repr(self.running) + ').read())', + self.debugMod.__dict__) self.progTerminated(res) def run_call(self, scriptname, func, *args): @@ -1972,7 +2041,8 @@ family = socket.AF_INET else: family = socket.AF_INET6 - return socket.getaddrinfo(host, None, family, socket.SOCK_STREAM)[0][4][0] + return socket.getaddrinfo(host, None, + family, socket.SOCK_STREAM)[0][4][0] def main(self): """ @@ -2095,7 +2165,8 @@ def close(self, fd): """ - Private method implementing a close method as a replacement for os.close(). + Private method implementing a close method as a replacement for + os.close(). It prevents the debugger connections from being closed. @@ -2115,7 +2186,8 @@ @param firstEntry entry to be put first in sys.path (string) @return path list for use as sys.path (list of strings) """ - sysPath = [path for path in os.environ.get("PYTHONPATH", "").split(os.pathsep) + sysPath = [path for path in os.environ.get("PYTHONPATH", "") + .split(os.pathsep) if path not in sys.path] + sys.path[:] if "" in sysPath: sysPath.remove("")
--- a/DebugClients/Python3/DebugClientThreads.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python3/DebugClientThreads.py Sun Oct 06 18:02:21 2013 +0200 @@ -35,7 +35,8 @@ @return The identifier of the created thread """ if DebugClientBase.DebugClientInstance is not None: - return DebugClientBase.DebugClientInstance.attachThread(target, args, kwargs) + return DebugClientBase.DebugClientInstance.attachThread( + target, args, kwargs) else: return _original_start_thread(target, args, kwargs) @@ -66,7 +67,8 @@ # protection lock for synchronization self.clientLock = RLock() - # the "current" thread, basically the thread we are at a breakpoint for. + # the "current" thread, basically the thread we are at a breakpoint + # for. self.currentThread = None # special objects representing the main scripts thread and frame @@ -75,14 +77,16 @@ self.variant = 'Threaded' - def attachThread(self, target=None, args=None, kwargs=None, mainThread=False): + def attachThread(self, target=None, args=None, kwargs=None, + mainThread=False): """ Public method to setup a thread for DebugClient to debug. If mainThread is non-zero, then we are attaching to the already started mainthread of the app and the rest of the args are ignored. - @param target the start function of the target thread (i.e. the user code) + @param target the start function of the target thread (i.e. the + user code) @param args arguments to pass to target @param kwargs keyword arguments to pass to target @param mainThread True, if we are attaching to the already
--- a/DebugClients/Python3/FlexCompleter.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python3/FlexCompleter.py Sun Oct 06 18:02:21 2013 +0200 @@ -187,7 +187,8 @@ try: if word[:n] == attr and hasattr(thisobject, word): val = getattr(thisobject, word) - word = self._callable_postfix(val, "{0}.{1}".format(expr, word)) + word = self._callable_postfix( + val, "{0}.{1}".format(expr, word)) matches.append(word) except: # some badly behaved objects pollute dir() with non-strings,
--- a/DebugClients/Python3/PyProfile.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python3/PyProfile.py Sun Oct 06 18:02:21 2013 +0200 @@ -168,6 +168,7 @@ "exception": profile.Profile.trace_dispatch_exception, "return": profile.Profile.trace_dispatch_return, "c_call": profile.Profile.trace_dispatch_c_call, - "c_exception": profile.Profile.trace_dispatch_return, # the C function returned + "c_exception": profile.Profile.trace_dispatch_return, + # the C function returned "c_return": profile.Profile.trace_dispatch_return, }
--- a/DebugClients/Python3/eric5dbgstub.py Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Python3/eric5dbgstub.py Sun Oct 06 18:02:21 2013 +0200 @@ -77,9 +77,12 @@ Module function used to start the remote debugger. @keyparam enableTrace flag to enable the tracing function (boolean) - @keyparam exceptions flag to enable exception reporting of the IDE (boolean) - @keyparam tracePython flag to enable tracing into the Python library (boolean) - @keyparam redirect flag indicating redirection of stdin, stdout and stderr (boolean) + @keyparam exceptions flag to enable exception reporting of the IDE + (boolean) + @keyparam tracePython flag to enable tracing into the Python library + (boolean) + @keyparam redirect flag indicating redirection of stdin, stdout and + stderr (boolean) """ global debugger if debugger:
--- a/DebugClients/Ruby/AsyncFile.rb Sun Oct 06 17:27:53 2013 +0200 +++ b/DebugClients/Ruby/AsyncFile.rb Sun Oct 06 18:02:21 2013 +0200 @@ -84,7 +84,8 @@ rescue IOError @nWriteErrors += 1 if @nWriteErrors > self.maxtries - raise # assume that an error that occurs 10 times wont go away + raise + # assume that an error that occurs 10 times wont go away end end end @@ -283,8 +284,8 @@ elsif @wpending.length + s.length > @@maxbuffersize # flush wpending if too big while @wpending.length > 0 - # if we have a persistent error in sending the data, an exception - # will be raised in nWrite + # if we have a persistent error in sending the data, an + # exception will be raised in nWrite flush tries += 1 if tries > @@maxtries