eric6/DebugClients/Python/DebugVariables.py

branch
maintenance
changeset 7642
72721823d453
parent 7639
422fd05e9c91
child 7862
817ef8e0fa66
child 7924
8a96736d465e
equal deleted inserted replaced
7608:f7cb83647621 7642:72721823d453
5 5
6 """ 6 """
7 Module implementing classes and functions to dump variable contents. 7 Module implementing classes and functions to dump variable contents.
8 """ 8 """
9 9
10 import sys
11
12 from DebugConfig import ConfigQtNames, ConfigKnownQtTypes, BatchSize 10 from DebugConfig import ConfigQtNames, ConfigKnownQtTypes, BatchSize
13 11
14 # 12 #
15 # This code was inspired by pydevd. 13 # This code was inspired by pydevd.
16 # 14 #
17
18 if sys.version_info[0] > 2:
19 basestring = str
20 15
21 ############################################################ 16 ############################################################
22 ## Classes implementing resolvers for various compund types 17 ## Classes implementing resolvers for various compund types
23 ############################################################ 18 ############################################################
24 19
56 d = {} 51 d = {}
57 for name in names: 52 for name in names:
58 try: 53 try:
59 attribute = getattr(var, name) 54 attribute = getattr(var, name)
60 d[name] = attribute 55 d[name] = attribute
61 except Exception: 56 except Exception: # secok
62 pass # if we can't get it, simply ignore it 57 pass # if we can't get it, simply ignore it
63 58
64 return d 59 return d
65 60
66 61
89 d = {} 84 d = {}
90 for name in names: 85 for name in names:
91 try: 86 try:
92 attribute = getattr(var, name) 87 attribute = getattr(var, name)
93 d[name] = attribute 88 d[name] = attribute
94 except Exception: 89 except Exception: # secok
95 pass # if we can't get it, simply ignore it 90 pass # if we can't get it, simply ignore it
96 91
97 yield -1, d 92 yield -1, d
98 while True: 93 while True:
99 yield -2, {} 94 yield -2, {}
139 @param key key to be converted 134 @param key key to be converted
140 @type any 135 @type any
141 @return string representation of the given key 136 @return string representation of the given key
142 @rtype str 137 @rtype str
143 """ 138 """
144 if isinstance(key, basestring): 139 if isinstance(key, str):
145 key = repr(key) 140 key = repr(key)
146 # Special handling for Python2 unicode strings and bytes object 141 # Special handling for Python2 unicode strings and bytes object
147 # Raw and f-Strings are always converted to (unicode) str 142 # Raw and f-Strings are always converted to (unicode) str
148 if key[0] in 'ub': 143 if key[0] in 'ub':
149 key = key[1:] 144 key = key[1:]
651 (frozenset, setResolver), 646 (frozenset, setResolver),
652 ] 647 ]
653 648
654 try: 649 try:
655 _TypeMap.append((long, None)) # __IGNORE_WARNING__ 650 _TypeMap.append((long, None)) # __IGNORE_WARNING__
656 except Exception: 651 except Exception: # secok
657 pass # not available on all Python versions 652 pass # not available on all Python versions
658 653
659 try: 654 try:
660 _TypeMap.append((unicode, None)) # __IGNORE_WARNING__ 655 _TypeMap.append((unicode, None)) # __IGNORE_WARNING__
661 except Exception: 656 except Exception: # secok
662 pass # not available on all Python versions 657 pass # not available on all Python versions
663 658
664 try: 659 try:
665 import array 660 import array
666 _TypeMap.append((array.array, arrayResolver)) 661 _TypeMap.append((array.array, arrayResolver))
718 break 713 break
719 else: 714 else:
720 resolver = defaultResolver 715 resolver = defaultResolver
721 716
722 return typeName, typeStr, resolver 717 return typeName, typeStr, resolver
723
724 #
725 # eflag: noqa = M702

eric ide

mercurial