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

Function internal_change_variable_json

_pydevd_bundle/pydevd_comm.py:906–952  ·  view source on GitHub ↗

The pydevd_vars.change_attr_expression(thread_id, frame_id, attr, value, dbg) can only deal with changing at a frame level, so, currently changing the contents of something in a different scope is currently not supported. :param SetVariableRequest request:

(py_db, request)

Source from the content-addressed store, hash-verified

904
905
906def internal_change_variable_json(py_db, request):
907 """
908 The pydevd_vars.change_attr_expression(thread_id, frame_id, attr, value, dbg) can only
909 deal with changing at a frame level, so, currently changing the contents of something
910 in a different scope is currently not supported.
911
912 :param SetVariableRequest request:
913 """
914 # : :type arguments: SetVariableArguments
915 arguments = request.arguments
916 variables_reference = arguments.variablesReference
917 scope = None
918 if isinstance_checked(variables_reference, ScopeRequest):
919 scope = variables_reference
920 variables_reference = variables_reference.variable_reference
921
922 fmt = arguments.format
923 if hasattr(fmt, "to_dict"):
924 fmt = fmt.to_dict()
925
926 try:
927 variable = py_db.suspended_frames_manager.get_variable(variables_reference)
928 except KeyError:
929 variable = None
930
931 if variable is None:
932 _write_variable_response(
933 py_db, request, value="", success=False, message="Unable to find variable container to change: %s." % (variables_reference,)
934 )
935 return
936
937 child_var = variable.change_variable(arguments.name, arguments.value, py_db, fmt=fmt, scope=scope)
938
939 if child_var is None:
940 _write_variable_response(py_db, request, value="", success=False, message="Unable to change: %s." % (arguments.name,))
941 return
942
943 var_data = child_var.get_var_data(fmt=fmt)
944 body = SetVariableResponseBody(
945 value=var_data["value"],
946 type=var_data["type"],
947 variablesReference=var_data.get("variablesReference"),
948 namedVariables=var_data.get("namedVariables"),
949 indexedVariables=var_data.get("indexedVariables"),
950 )
951 variables_response = pydevd_base_schema.build_response(request, kwargs={"body": body})
952 py_db.writer.add_command(NetCommand(CMD_RETURN, 0, variables_response, is_json=True))
953
954
955def _write_variable_response(py_db, request, value, success, message):

Callers

nothing calls this directly

Calls 10

isinstance_checkedFunction · 0.90
NetCommandClass · 0.90
_write_variable_responseFunction · 0.85
get_var_dataMethod · 0.80
to_dictMethod · 0.45
get_variableMethod · 0.45
change_variableMethod · 0.45
getMethod · 0.45
add_commandMethod · 0.45

Tested by

no test coverage detected