Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress errors for unused object slots #292

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _pydevd_bundle/pydevd_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ def _get_py_dictionary(self, var, names=None, used___dict__=False):
name_as_str = "%r" % (name_as_str,)

if not used___dict__:
if not hasattr(var, name):
continue
attr = getattr(var, name)
else:
attr = var.__dict__[name]
Expand Down
22 changes: 22 additions & 0 deletions tests_python/test_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,28 @@ def __getattribute__(self, attr_name):
assert type_name == "MyObject"


def test_object_resolver_empty_slot():
from _pydevd_bundle.pydevd_resolver import DefaultResolver

default_resolver = DefaultResolver()

class MyObject(object):
__slots__ = ["a", "b", "c"]

def __init__(self):
self.a = 1
self.c = 3

obj = MyObject()
dictionary = default_resolver.get_dictionary(obj)

dictionary = clear_contents_dictionary(default_resolver.get_dictionary(obj))
assert dictionary == {"a": 1, "c": 3}

contents_debug_adapter_protocol = clear_contents_debug_adapter_protocol(default_resolver.get_contents_debug_adapter_protocol(obj))
assert contents_debug_adapter_protocol == [("a", 1, ".a"), ("c", 3, ".c")]


def test_object_resolver__dict__non_strings():
from _pydevd_bundle.pydevd_resolver import DefaultResolver

Expand Down