Skip to content

Commit

Permalink
Fix issue resolving tuple with object attributes. Fixes microsoft#1277
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Apr 1, 2019
1 parent a2e7fd1 commit 2efe766
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 19 additions & 2 deletions src/ptvsd/_vendored/pydevd/tests_python/test_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -278,4 +279,20 @@ def test_tuple_resolver():
'0x8': 8,
'0x9': 9,
'__len__': 10
}
}


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]'), ]

0 comments on commit 2efe766

Please sign in to comment.