Revert "PY-73427 Experiment: always load self variable in safe manner"

This reverts commit dcdf3d070f71e3ad47055fc7620d4d53e5fc3c4f.

GitOrigin-RevId: 3f33fd05916cc4bed1c5f9ed9a2a30e608d94f76
This commit is contained in:
Andrey Lisin
2024-06-28 13:34:05 +02:00
committed by intellij-monorepo-bot
parent 16b184ae3b
commit 5c4c5ad909
2 changed files with 16 additions and 28 deletions

View File

@@ -191,7 +191,6 @@ if os.getenv('PYDEVD_LOAD_VALUES_ASYNC', 'False') == 'True':
LOAD_VALUES_POLICY = ValuesPolicy.ASYNC
if os.getenv('PYDEVD_LOAD_VALUES_ON_DEMAND', 'False') == 'True':
LOAD_VALUES_POLICY = ValuesPolicy.ON_DEMAND
SELF_VALUES_LOAD_POLICY = ValuesPolicy.ON_DEMAND
DEFAULT_VALUES_DICT = {ValuesPolicy.ASYNC: "__pydevd_value_async", ValuesPolicy.ON_DEMAND: "__pydevd_value_on_demand"}
INTERACTIVE_MODE_AVAILABLE = sys.platform in ('darwin', 'win32') or os.getenv('DISPLAY') is not None

View File

@@ -11,20 +11,14 @@ from _pydev_bundle import pydev_log
from _pydev_bundle.pydev_imports import quote
from _pydevd_bundle import pydevd_extension_utils
from _pydevd_bundle import pydevd_resolver
from _pydevd_bundle.pydevd_constants import dict_keys, IS_PY3K, \
LOAD_VALUES_POLICY, \
DEFAULT_VALUES_DICT, \
SELF_VALUES_LOAD_POLICY
from _pydevd_bundle.pydevd_extension_api import TypeResolveProvider, \
StrPresentationProvider
from _pydevd_bundle.pydevd_frame_type_handler import get_vars_handler, \
DO_NOT_PROCESS_VARS, XML_COMMUNICATION_VARS_HANDLER
from _pydevd_bundle.pydevd_constants import dict_iter_items, dict_keys, IS_PY3K, \
MAXIMUM_VARIABLE_REPRESENTATION_SIZE, RETURN_VALUES_DICT, LOAD_VALUES_POLICY, DEFAULT_VALUES_DICT, \
GET_FRAME_RETURN_GROUP
from _pydevd_bundle.pydevd_extension_api import TypeResolveProvider, StrPresentationProvider
from _pydevd_bundle.pydevd_user_type_renderers_utils import try_get_type_renderer_for_var
from _pydevd_bundle.pydevd_utils import is_string, should_evaluate_full_value, should_evaluate_shape
from _pydevd_bundle.pydevd_frame_type_handler import get_vars_handler, DO_NOT_PROCESS_VARS, XML_COMMUNICATION_VARS_HANDLER
from _pydevd_bundle.pydevd_repr_utils import get_value_repr
from _pydevd_bundle.pydevd_user_type_renderers_utils import \
try_get_type_renderer_for_var
from _pydevd_bundle.pydevd_utils import is_string, should_evaluate_full_value, \
should_evaluate_shape
try:
import types
@@ -296,8 +290,6 @@ def var_to_xml(val, name, do_trim=True, additional_in_xml='', evaluate_full_valu
xml = '<var name="%s" ' % (make_valid_xml_value(name))
return ''.join((xml, ' />\n'))
is_self = name == 'self'
try:
# This should be faster than isinstance (but we have to protect against not having a '__class__' attribute).
is_exception_on_eval = val.__class__ == ExceptionOnEvaluate
@@ -336,9 +328,7 @@ def var_to_xml(val, name, do_trim=True, additional_in_xml='', evaluate_full_valu
# value to xml
value = None
if is_self:
value = DEFAULT_VALUES_DICT[SELF_VALUES_LOAD_POLICY]
elif not evaluate_full_value:
if not evaluate_full_value:
value = DEFAULT_VALUES_DICT[LOAD_VALUES_POLICY]
elif type_renderer is not None:
value = type_renderer.evaluate_var_string_repr(v)
@@ -349,15 +339,14 @@ def var_to_xml(val, name, do_trim=True, additional_in_xml='', evaluate_full_valu
# shape to xml
xml_shape = ''
if not is_self:
try:
if should_evaluate_shape():
if hasattr(v, 'shape') and not callable(v.shape):
xml_shape = ' shape="%s"' % make_valid_xml_value(str(tuple(v.shape)))
elif hasattr(v, '__len__') and not is_string(v):
xml_shape = ' shape="%s"' % make_valid_xml_value("%s" % str(len(v)))
except:
pass
try:
if should_evaluate_shape():
if hasattr(v, 'shape') and not callable(v.shape):
xml_shape = ' shape="%s"' % make_valid_xml_value(str(tuple(v.shape)))
elif hasattr(v, '__len__') and not is_string(v):
xml_shape = ' shape="%s"' % make_valid_xml_value("%s" % str(len(v)))
except:
pass
# additional info to xml
if is_exception_on_eval: