MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / _get_py_dictionary

Method _get_py_dictionary

_pydevd_bundle/pydevd_resolver.py:163–212  ·  view source on GitHub ↗

:return tuple(names, used___dict__), where used___dict__ means we have to access using obj.__dict__[name] instead of getattr(obj, name)

(self, var, names=None, used___dict__=False)

Source from the content-addressed store, hash-verified

161 return names, used___dict__
162
163 def _get_py_dictionary(self, var, names=None, used___dict__=False):
164 """
165 :return tuple(names, used___dict__), where used___dict__ means we have to access
166 using obj.__dict__[name] instead of getattr(obj, name)
167 """
168
169 # On PyPy we never show functions. This is because of a corner case where PyPy becomes
170 # absurdly slow -- it takes almost half a second to introspect a single numpy function (so,
171 # the related test, "test_case_16_resolve_numpy_array", times out... this probably isn't
172 # specific to numpy, but to any library where the CPython bridge is used, but as we
173 # can't be sure in the debugger, we play it safe and don't show it at all).
174 filter_function = IS_PYPY
175
176 if not names:
177 names, used___dict__ = self.get_names(var)
178 d = {}
179
180 # Be aware that the order in which the filters are applied attempts to
181 # optimize the operation by removing as many items as possible in the
182 # first filters, leaving fewer items for later filters
183
184 timer = Timer()
185 cls = type(var)
186 for name in names:
187 try:
188 name_as_str = name
189 if name_as_str.__class__ != str:
190 name_as_str = "%r" % (name_as_str,)
191
192 if not used___dict__:
193 attr = getattr(var, name)
194 else:
195 attr = var.__dict__[name]
196
197 # filter functions?
198 if filter_function:
199 if inspect.isroutine(attr) or isinstance(attr, MethodWrapperType):
200 continue
201 except:
202 # if some error occurs getting it, let's put it to the user.
203 strIO = StringIO()
204 traceback.print_exc(file=strIO)
205 attr = strIO.getvalue()
206
207 finally:
208 timer.report_if_getting_attr_slow(cls, name_as_str)
209
210 d[name_as_str] = attr
211
212 return d, used___dict__
213
214
215class DAPGrouperResolver:

Callers 2

get_dictionaryMethod · 0.95

Calls 5

get_namesMethod · 0.95
TimerClass · 0.90
isroutineMethod · 0.80
getvalueMethod · 0.80

Tested by

no test coverage detected