25 |
25 |
26 import DebugClientCapabilities |
26 import DebugClientCapabilities |
27 import DebugVariables |
27 import DebugVariables |
28 from DebugBase import setRecursionLimit, printerr # __IGNORE_WARNING__ |
28 from DebugBase import setRecursionLimit, printerr # __IGNORE_WARNING__ |
29 from AsyncFile import AsyncFile, AsyncPendingWrite |
29 from AsyncFile import AsyncFile, AsyncPendingWrite |
30 from DebugConfig import ConfigQtNames, ConfigVarTypeStrings |
30 from DebugConfig import ConfigQtNames, SpecialAttributes |
31 from FlexCompleter import Completer |
31 from FlexCompleter import Completer |
32 from DebugUtilities import prepareJsonCommand |
32 from DebugUtilities import prepareJsonCommand |
33 from BreakpointWatch import Breakpoint, Watch |
33 from BreakpointWatch import Breakpoint, Watch |
34 ##from MultiProcessDebugExtension import patchNewProcessFunctions |
34 ##from MultiProcessDebugExtension import patchNewProcessFunctions |
35 |
35 |
1771 @param scope 1 to filter using the globals filter, 0 using the locals |
1771 @param scope 1 to filter using the globals filter, 0 using the locals |
1772 filter. |
1772 filter. |
1773 Variables are only added to the list, if their name do not match |
1773 Variables are only added to the list, if their name do not match |
1774 any of the filter expressions. |
1774 any of the filter expressions. |
1775 @type int |
1775 @type int |
1776 @param filterList the indices of variable types to be filtered. |
1776 @param filterList list of variable types to be filtered. |
1777 Variables are only added to the list, if their type is not |
1777 Variables are only added to the list, if their type is not |
1778 contained in the filter list. |
1778 contained in the filter list. |
1779 @type list of int |
1779 @type list of str |
1780 @return A tuple consisting of a list of formatted variables. Each |
1780 @return A tuple consisting of a list of formatted variables. Each |
1781 variable entry is a tuple of three elements, the variable name, |
1781 variable entry is a tuple of three elements, the variable name, |
1782 its type and value. |
1782 its type and value. |
1783 @rtype list of tuple of (str, str, str) |
1783 @rtype list of tuple of (str, str, str) |
1784 """ |
1784 """ |
1805 break |
1805 break |
1806 if matched: |
1806 if matched: |
1807 continue |
1807 continue |
1808 |
1808 |
1809 # filter hidden attributes (filter #0) |
1809 # filter hidden attributes (filter #0) |
1810 if 0 in filterList and str(key)[:2] == '__': |
1810 if '__' in filterList and str(key)[:2] == '__': |
1811 continue |
1811 continue |
1812 |
1812 |
1813 # special handling for '__builtins__' (it's way too big) |
1813 # special handling for '__builtins__' (it's way too big) |
1814 if key == '__builtins__': |
1814 if key == '__builtins__': |
1815 rvalue = '<module builtins (built-in)>' |
1815 rvalue = '<module builtins (built-in)>' |
1816 valtype = 'module' |
1816 valtype = 'module' |
1817 if ConfigVarTypeStrings.index(valtype) in filterList: |
1817 if valtype in filterList: |
1818 continue |
1818 continue |
|
1819 elif ( |
|
1820 key in SpecialAttributes and |
|
1821 "special_attributes" in filterList |
|
1822 ): |
|
1823 continue |
|
1824 elif ( |
|
1825 key == "__hash__" and |
|
1826 "builtin_function_or_method" in filterList |
|
1827 ): |
|
1828 continue |
1819 else: |
1829 else: |
1820 isQt = False |
1830 isQt = False |
1821 # valtypestr, e.g. class 'PyQt5.QtCore.QPoint' |
1831 # valtypestr, e.g. class 'PyQt5.QtCore.QPoint' |
1822 valtypestr = str(type(value))[1:-1] |
1832 valtypestr = str(type(value))[1:-1] |
1823 _, valtype = valtypestr.split(' ', 1) |
1833 _, valtype = valtypestr.split(' ', 1) |
1824 # valtype, e.g. PyQt5.QtCore.QPoint |
1834 # valtype, e.g. PyQt5.QtCore.QPoint |
1825 valtype = valtype[1:-1] |
1835 valtype = valtype[1:-1] |
1826 # Strip 'instance' to be equal with Python 3 |
1836 # Strip 'instance' to be equal with Python 3 |
1827 if valtype == "instancemethod": |
1837 if valtype == "instancemethod": |
1828 valtype = "method" |
1838 valtype = "method" |
1829 elif valtype == "type" or valtype == "classobj": |
1839 elif valtype in ("type", "classobj"): |
1830 valtype = "class" |
1840 valtype = "class" |
|
1841 elif valtype == "method-wrapper": |
|
1842 valtype = "builtin_function_or_method" |
1831 |
1843 |
1832 # valtypename, e.g. QPoint |
1844 # valtypename, e.g. QPoint |
1833 valtypename = type(value).__name__ |
1845 valtypename = type(value).__name__ |
1834 try: |
1846 if valtype in filterList: |
1835 if ConfigVarTypeStrings.index(valtype) in filterList: |
1847 continue |
1836 continue |
1848 elif ( |
1837 except ValueError: |
1849 valtype in ("sip.enumtype", "sip.wrappertype") and |
1838 if valtype in ("sip.enumtype", "sip.wrappertype"): |
1850 'class' in filterList |
1839 if ConfigVarTypeStrings.index('class') in filterList: |
1851 ): |
1840 continue |
1852 continue |
1841 elif (valtype == "sip.methoddescriptor" or |
1853 elif ( |
1842 valtype == "method_descriptor"): |
1854 valtype in ( |
1843 if ConfigVarTypeStrings.index('method') in filterList: |
1855 "sip.methoddescriptor", "method_descriptor") and |
1844 continue |
1856 'method' in filterList |
1845 elif valtype in ("numpy.ndarray", "array.array"): |
1857 ): |
1846 if ConfigVarTypeStrings.index('list') in filterList: |
1858 continue |
1847 continue |
1859 elif ( |
1848 elif valtypename == "MultiValueDict": |
1860 valtype in ("numpy.ndarray", "array.array") and |
1849 if ConfigVarTypeStrings.index('dict') in filterList: |
1861 'list' in filterList |
1850 continue |
1862 ): |
1851 elif ConfigVarTypeStrings.index('instance') in filterList: |
1863 continue |
1852 continue |
1864 elif valtypename == "MultiValueDict" and 'dict' in filterList: |
1853 |
1865 continue |
1854 isQt = valtype.startswith(ConfigQtNames) |
1866 elif 'instance' in filterList: |
1855 if (not valtypestr.startswith('type ') and |
1867 continue |
1856 valtypename not in ("ndarray", "MultiValueDict", |
1868 |
1857 "array", "defaultdict") and |
1869 isQt = valtype.startswith(ConfigQtNames) |
1858 not isQt): |
1870 # TODO: see if this is still needed |
1859 valtype = valtypestr |
1871 # if (not valtypestr.startswith('type ') and |
|
1872 # valtypename not in ("ndarray", "MultiValueDict", |
|
1873 # "array", "defaultdict") and |
|
1874 # not isQt): |
|
1875 # valtype = valtypestr |
1860 |
1876 |
1861 try: |
1877 try: |
1862 if valtype in self.arrayTypes: |
1878 if valtype in self.arrayTypes: |
1863 rvalue = "{0:d}".format(len(value)) |
1879 rvalue = "{0:d}".format(len(value)) |
1864 elif valtype == 'array.array': |
1880 elif valtype == 'array.array': |