Sat, 27 Apr 2019 22:06:38 +0200
Improved determination of expandable items including removing 'other' as selectable type.
Variables of unknown type are now count as instances.
--- a/eric6/DebugClients/Python/DebugClientBase.py Mon Apr 22 10:38:32 2019 +0200 +++ b/eric6/DebugClients/Python/DebugClientBase.py Sat Apr 27 22:06:38 2019 +0200 @@ -1533,7 +1533,14 @@ # If found, get the details of attribute if variable is not None: typeName, typeStr, resolver = DebugVariables.getType(variable) - if typeStr.startswith(ConfigQtNames): + if resolver: + varGen = resolver.getDictionary(variable) + self.resolverCache[scope][str(var)] = varGen + + idx, varDict = next(varGen) + varlist = self.__formatVariablesList( + varDict, scope, filterList) + else: # Gently handle exception which could occure as special # cases, e.g. already deleted C++ objects, str conversion.. try: @@ -1541,13 +1548,6 @@ except Exception: varlist = [] idx = -1 - elif resolver: - varGen = resolver.getDictionary(variable) - self.resolverCache[scope][str(var)] = varGen - - idx, varDict = next(varGen) - varlist = self.__formatVariablesList( - varDict, scope, filterList) var.insert(0, idx) @@ -1781,44 +1781,49 @@ if key == '__builtins__': rvalue = '<module __builtin__ (built-in)>' valtype = 'module' + if ConfigVarTypeStrings.index(valtype) in filterList: + continue else: + isQt = False + # valtypestr, e.g. class 'PyQt5.QtCore.QPoint' valtypestr = str(type(value))[1:-1] _, valtype = valtypestr.split(' ', 1) + # valtype, e.g. PyQt5.QtCore.QPoint valtype = valtype[1:-1] # Strip 'instance' to be equal with Python 3 if valtype == "instancemethod": valtype = "method" + elif valtype == "type" or valtype == "classobj": + valtype = "class" + # valtypename, e.g. QPoint valtypename = type(value).__name__ try: if ConfigVarTypeStrings.index(valtype) in filterList: continue except ValueError: - if valtype == "classobj": - if ConfigVarTypeStrings.index( - 'instance') in filterList: + if valtype == "sip.enumtype": + if ConfigVarTypeStrings.index('class') in filterList: continue - elif valtype == "sip.methoddescriptor": + elif (valtype == "sip.methoddescriptor" or + valtype == "method_descriptor"): if ConfigVarTypeStrings.index('method') in filterList: continue - elif valtype == "sip.enumtype": - if ConfigVarTypeStrings.index('class') in filterList: - continue - elif not valtype.startswith(("PySide.", "PySide2.")) and \ - (ConfigVarTypeStrings.index('other') in - filterList): - continue - elif valtype in ["numpy.ndarray", "array.array"]: + elif valtype in ("numpy.ndarray", "array.array"): if ConfigVarTypeStrings.index('list') in filterList: continue elif valtypename == "MultiValueDict": if ConfigVarTypeStrings.index('dict') in filterList: continue + elif ConfigVarTypeStrings.index('instance') in filterList: + continue + isQt = valtype.startswith(ConfigQtNames) if (not valtypestr.startswith('type ') and - valtypename not in - ["ndarray", "MultiValueDict", "array"] and - not valtype.startswith(('PyQt5.', 'PyQt4.'))): + valtypename not in ( + "ndarray", "MultiValueDict", "array", + "defaultdict" + ) and not isQt): # __IGNORE_WARNING_E123__ valtype = valtypestr try: @@ -1838,11 +1843,9 @@ valtype = "django.MultiValueDict" # shortened type else: rvalue = repr(value) - if valtype.startswith('class') and \ - rvalue[0] in ['{', '(', '[']: + if valtype.startswith('class') and rvalue[0] in '{([': rvalue = "" - elif (rvalue.startswith("<class '") and - valtype.startswith(ConfigQtNames)): + elif (isQt and rvalue.startswith("<class '")): rvalue = rvalue[8:-2] except Exception: rvalue = ''
--- a/eric6/DebugClients/Python/DebugConfig.py Mon Apr 22 10:38:32 2019 +0200 +++ b/eric6/DebugClients/Python/DebugConfig.py Sat Apr 27 22:06:38 2019 +0200 @@ -18,7 +18,7 @@ 'slice', 'buffer', 'class', 'instance', 'method', 'property', 'generator', 'function', 'builtin_function_or_method', 'code', 'module', - 'ellipsis', 'traceback', 'frame', 'other', 'frozenset', + 'ellipsis', 'traceback', 'frame', 'other', 'frozenset', 'bytes', # Special case for Python 2: don't add 'instancemethod' to # ConfigVarTypeFilters and leave it always at last position 'instancemethod' @@ -26,7 +26,7 @@ BatchSize = 200 ConfigQtNames = ( - 'PyQt5.', 'PyQt4.', 'PySide2.', 'PySide.', 'Shiboken.' + 'PyQt5.', 'PyQt4.', 'PySide2.', 'PySide.', 'Shiboken.EnumType' ) ConfigKnownQtTypes = ( '.QChar', '.QByteArray', '.QString', '.QStringList', '.QPoint', '.QPointF',
--- a/eric6/DebugClients/Python/DebugVariables.py Mon Apr 22 10:38:32 2019 +0200 +++ b/eric6/DebugClients/Python/DebugVariables.py Sat Apr 27 22:06:38 2019 +0200 @@ -9,7 +9,7 @@ import sys -from DebugConfig import ConfigQtNames, BatchSize +from DebugConfig import ConfigQtNames, ConfigKnownQtTypes, BatchSize # # This code was inspired by pydevd. @@ -657,7 +657,8 @@ typeStr = str(typeObject).split(' ', 1)[-1] typeStr = typeStr[1:-2] - if typeStr.startswith(ConfigQtNames): + if (typeStr.startswith(ConfigQtNames) and + typeStr.endswith(ConfigKnownQtTypes)): resolver = None else: if _TypeMap is None:
--- a/eric6/Debugger/Config.py Mon Apr 22 10:38:32 2019 +0200 +++ b/eric6/Debugger/Config.py Sat Apr 27 22:06:38 2019 +0200 @@ -48,7 +48,7 @@ 'ellipsis': QT_TRANSLATE_NOOP('Variable Types', 'Ellipsis'), 'traceback': QT_TRANSLATE_NOOP('Variable Types', 'Traceback'), 'frame': QT_TRANSLATE_NOOP('Variable Types', 'Frame'), - 'other': QT_TRANSLATE_NOOP('Variable Types', 'Other'), + 'bytes': QT_TRANSLATE_NOOP('Variable Types', 'Bytes'), } @@ -84,6 +84,7 @@ 'ellipsis': 28, 'traceback': 29, 'frame': 30, - 'other': 31, + 'other': 31, # Not used anymore but keep to avoid reassignment 'frozenset': 32, + 'bytes': 33, }
--- a/eric6/Debugger/VariablesViewer.py Mon Apr 22 10:38:32 2019 +0200 +++ b/eric6/Debugger/VariablesViewer.py Sat Apr 27 22:06:38 2019 +0200 @@ -131,15 +131,21 @@ # Python class? if dtype.startswith('class '): dtype = dtype[7:-1] - self.hasChilds = True - elif dtype == 'classobj': - dtype = 'instance' + if dtype not in ('method_descriptor', 'wrapper_descriptor'): + self.hasChilds = True # Qt related stuff? elif (dtype.startswith(ConfigQtNames) and dtype.endswith(ConfigKnownQtTypes)): self.hasChilds = True + + elif dtype in ('instance', 'class'): + self.hasChilds = True vtype = ConfigVarTypeDispStrings.get(dtype, dtype) + # Unkown types should be expandable by default + if (vtype is dtype and + dtype not in ('method_descriptor', 'wrapper_descriptor')): + self.hasChilds = True self.type = QCoreApplication.translate("VariablesViewer", vtype) def __getValue(self, dtype, dvalue): @@ -183,7 +189,7 @@ try: dvalue = str(dvalue) except UnicodeDecodeError: # Never reached under Python 3 - dvalue = unicode(dvalue, 'utf-8') + dvalue = unicode(dvalue, 'utf-8') # __IGNORE_WARNING__ self.value = dvalue