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

Class InternalGetVariable

_pydevd_bundle/pydevd_comm.py:816–857  ·  view source on GitHub ↗

gets the value of a variable

Source from the content-addressed store, hash-verified

814
815
816class InternalGetVariable(InternalThreadCommand):
817 """gets the value of a variable"""
818
819 def __init__(self, seq, thread_id, frame_id, scope, attrs):
820 self.sequence = seq
821 self.thread_id = thread_id
822 self.frame_id = frame_id
823 self.scope = scope
824 self.attributes = attrs
825
826 @silence_warnings_decorator
827 def do_it(self, dbg):
828 """Converts request into python variable"""
829 try:
830 xml = StringIO()
831 xml.write("<xml>")
832 type_name, val_dict = pydevd_vars.resolve_compound_variable_fields(
833 dbg, self.thread_id, self.frame_id, self.scope, self.attributes
834 )
835 if val_dict is None:
836 val_dict = {}
837
838 # assume properly ordered if resolver returns 'OrderedDict'
839 # check type as string to support OrderedDict backport for older Python
840 keys = list(val_dict)
841 if not (type_name == "OrderedDict" or val_dict.__class__.__name__ == "OrderedDict" or IS_PY36_OR_GREATER):
842 keys = sorted(keys, key=compare_object_attrs_key)
843
844 timer = Timer()
845 for k in keys:
846 val = val_dict[k]
847 evaluate_full_value = pydevd_xml.should_evaluate_full_value(val)
848 xml.write(pydevd_xml.var_to_xml(val, k, evaluate_full_value=evaluate_full_value))
849 timer.report_if_compute_repr_attr_slow(self.attributes, k, type(val))
850
851 xml.write("</xml>")
852 cmd = dbg.cmd_factory.make_get_variable_message(self.sequence, xml.getvalue())
853 xml.close()
854 dbg.writer.add_command(cmd)
855 except Exception:
856 cmd = dbg.cmd_factory.make_error_message(self.sequence, "Error resolving variables %s" % (get_exception_traceback_str(),))
857 dbg.writer.add_command(cmd)
858
859
860class InternalGetArray(InternalThreadCommand):

Callers 1

request_get_variableMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected