From 2efe766bf70d433d954a8db40e2b15fd14950f45 Mon Sep 17 00:00:00 2001 From: fabioz Date: Mon, 1 Apr 2019 08:13:56 -0300 Subject: [PATCH] Fix issue resolving tuple with object attributes. Fixes #1277 --- .../pydevd/_pydevd_bundle/pydevd_resolver.py | 2 +- .../pydevd/tests_python/test_resolvers.py | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py b/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py index f497b8b78..1fa6c0de8 100644 --- a/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py +++ b/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py @@ -369,7 +369,7 @@ def get_contents_debug_adapter_protocol(self, lst, fmt=None): ret.append(('__len__', len(lst), partial(_apply_evaluate_name, evaluate_name='len(%s)'))) # Needed in case the class extends the built-in type and has some additional fields. - from_default_resolver = defaultResolver.get_dictionary(lst) + from_default_resolver = defaultResolver.get_contents_debug_adapter_protocol(lst, fmt=fmt) if from_default_resolver: ret = from_default_resolver + ret return ret diff --git a/src/ptvsd/_vendored/pydevd/tests_python/test_resolvers.py b/src/ptvsd/_vendored/pydevd/tests_python/test_resolvers.py index 2997e600c..72a91a2e1 100644 --- a/src/ptvsd/_vendored/pydevd/tests_python/test_resolvers.py +++ b/src/ptvsd/_vendored/pydevd/tests_python/test_resolvers.py @@ -21,6 +21,7 @@ def test_dict_resolver(): assert contents_debug_adapter_protocol == [ ("'22'", 22, "['22']"), ('(1, 2)', 2, '[(1, 2)]')] + def test_dict_resolver_hex(): from _pydevd_bundle.pydevd_resolver import DictResolver dict_resolver = DictResolver() @@ -140,7 +141,7 @@ def __init__(self): def test_tuple_resolver(): from _pydevd_bundle.pydevd_resolver import TupleResolver tuple_resolver = TupleResolver() - fmt={'hex': True} + fmt = {'hex': True} lst = tuple(range(11)) contents_debug_adapter_protocol = tuple_resolver.get_contents_debug_adapter_protocol(lst) len_entry = contents_debug_adapter_protocol.pop(-1) @@ -278,4 +279,20 @@ def test_tuple_resolver(): '0x8': 8, '0x9': 9, '__len__': 10 - } \ No newline at end of file + } + + +def test_tuple_resolver_mixed(): + from _pydevd_bundle.pydevd_resolver import TupleResolver + tuple_resolver = TupleResolver() + + class CustomTuple(tuple): + pass + + my_tuple = CustomTuple([1, 2]) + my_tuple.some_value = 10 + contents_debug_adapter_protocol = tuple_resolver.get_contents_debug_adapter_protocol(my_tuple) + len_entry = contents_debug_adapter_protocol.pop(-1) + check_len_entry(len_entry, ('__len__', 2)) + assert contents_debug_adapter_protocol == [ + ('some_value', 10, '.some_value'), ('0', 1, '[0]'), ('1', 2, '[1]'), ]