mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix expanding returned values in Variables Pane (PY-13540)
This commit is contained in:
@@ -37,6 +37,8 @@ except AttributeError:
|
||||
#the communication slower -- as the variables are being gathered lazily in the latest version of eclipse,
|
||||
#this value was raised from 200 to 1000.
|
||||
MAXIMUM_VARIABLE_REPRESENTATION_SIZE = 1000
|
||||
# Prefix for saving functions return values in locals
|
||||
RETURN_VALUES_PREFIX = '__pydevd_ret_val_'
|
||||
|
||||
import os
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from _pydevd_bundle.pydevd_breakpoints import get_exception_breakpoint
|
||||
from _pydevd_bundle.pydevd_comm import CMD_STEP_CAUGHT_EXCEPTION, CMD_STEP_RETURN, CMD_STEP_OVER, CMD_SET_BREAK, \
|
||||
CMD_STEP_INTO, CMD_SMART_STEP_INTO, CMD_RUN_TO_LINE, CMD_SET_NEXT_STATEMENT, CMD_STEP_INTO_MY_CODE
|
||||
from _pydevd_bundle.pydevd_constants import STATE_SUSPEND, dict_contains, get_thread_id, STATE_RUN, dict_iter_values, IS_PY3K, \
|
||||
dict_keys, dict_pop
|
||||
dict_keys, dict_pop, RETURN_VALUES_PREFIX
|
||||
from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE, PYDEV_FILE
|
||||
from _pydevd_bundle.pydevd_frame_utils import add_exception_to_frame, just_raised
|
||||
from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame
|
||||
@@ -266,18 +266,25 @@ class PyDBFrame: # No longer cdef because object was dying when only a reference
|
||||
thread = None
|
||||
|
||||
def manage_return_values(self, main_debugger, frame, event, arg):
|
||||
if main_debugger.show_return_values:
|
||||
if event == "return" and hasattr(frame, "f_code") and hasattr(frame.f_code, "co_name"):
|
||||
name = frame.f_code.co_name
|
||||
if hasattr(frame, "f_back") and hasattr(frame.f_back, "f_locals"):
|
||||
frame.f_back.f_locals["__pydevd_ret_val" + name] = arg
|
||||
elif main_debugger.remove_return_values_flag:
|
||||
# show return values was turned off, we should remove them from locals dict
|
||||
if hasattr(frame, "f_back") and hasattr(frame.f_back, "f_locals"):
|
||||
for var_name in dict_keys(frame.f_back.f_locals):
|
||||
if var_name.startswith("__pydevd_ret_val"):
|
||||
try:
|
||||
if main_debugger.show_return_values:
|
||||
if event == "return" and hasattr(frame, "f_code") and hasattr(frame.f_code, "co_name"):
|
||||
name = frame.f_code.co_name
|
||||
if hasattr(frame, "f_back") and hasattr(frame.f_back, "f_locals"):
|
||||
frame.f_back.f_locals[RETURN_VALUES_PREFIX + name] = arg
|
||||
elif main_debugger.remove_return_values_flag:
|
||||
# show return values was turned off, we should remove them from locals dict
|
||||
for var_name in dict_keys(frame.f_locals):
|
||||
if var_name.startswith(RETURN_VALUES_PREFIX):
|
||||
dict_pop(frame.f_back.f_locals, var_name)
|
||||
if hasattr(frame, "f_back") and hasattr(frame.f_back, "f_locals"):
|
||||
for var_name in dict_keys(frame.f_back.f_locals):
|
||||
if var_name.startswith(RETURN_VALUES_PREFIX):
|
||||
dict_pop(frame.f_back.f_locals, var_name)
|
||||
main_debugger.remove_return_values_flag = False
|
||||
except:
|
||||
main_debugger.remove_return_values_flag = False
|
||||
traceback.print_exc()
|
||||
|
||||
# IFDEF CYTHON
|
||||
# def trace_dispatch(self, frame, str event, arg):
|
||||
|
||||
@@ -239,8 +239,8 @@ def var_to_xml(val, name, doTrim=True, additionalInXml=''):
|
||||
except:
|
||||
pass
|
||||
|
||||
if name.startswith("__pydevd_ret_val"):
|
||||
name = name.split("__pydevd_ret_val")[1]
|
||||
if name.startswith(RETURN_VALUES_PREFIX):
|
||||
name = name.split(RETURN_VALUES_PREFIX)[1]
|
||||
xmlRetVal = ' isRetVal="True"'
|
||||
else:
|
||||
xmlRetVal = ''
|
||||
|
||||
@@ -19,6 +19,8 @@ public class PyDebugValue extends XNamedValue {
|
||||
private static final Logger LOG = Logger.getInstance("#com.jetbrains.python.pydev.PyDebugValue");
|
||||
public static final int MAX_VALUE = 256;
|
||||
|
||||
public static final String RETURN_VALUES_PREFIX = "__pydevd_ret_val_";
|
||||
|
||||
private String myTempName = null;
|
||||
private final String myType;
|
||||
private final String myTypeQualifier;
|
||||
|
||||
@@ -608,7 +608,11 @@ public class PyDebugProcess extends XDebugProcess implements IPyDebugProcess, Pr
|
||||
@Override
|
||||
public XValueChildrenList loadVariable(final PyDebugValue var) throws PyDebuggerException {
|
||||
final PyStackFrame frame = currentFrame();
|
||||
return myDebugger.loadVariable(frame.getThreadId(), frame.getFrameId(), var);
|
||||
PyDebugValue debugValue = var;
|
||||
if (var.isReturnedVal()) {
|
||||
debugValue = var.setName(PyDebugValue.RETURN_VALUES_PREFIX + var.getName());
|
||||
}
|
||||
return myDebugger.loadVariable(frame.getThreadId(), frame.getFrameId(), debugValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user