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

Acccessing a faulty property of an instrument throws obscure error. #5518

Open
qutech-lab opened this issue Nov 14, 2023 · 0 comments
Open

Comments

@qutech-lab
Copy link

Acccessing a faulty property of an instrument raises obscure error.

If an instrument has a property which raises an exception when gotten, the resulting error trace obscures the source of the error.

Steps to reproduce

Take the following subclass of an instrument:

In [1]: import qcodes

In [2]: class Foo(qcodes.Instrument):
   ...:    @property
   ...:    def foo(self):
   ...:        return self.bar

Accessing the foo property raises the following error, which has no traceback or reference whatsoever to what actually causes the error, which is the missing bar attribute:

In [3]: foo = Foo('foo')
In [4]: foo.foo
Traceback (most recent call last):

  Cell In[4], line 1
    foo.foo

  File ~\Documents\Qcodes\src\qcodes\utils\attribute_helpers.py:69 in __getattr__
    raise AttributeError(

AttributeError: 'Foo' object and its delegates have no attribute 'foo'

This behavior makes these sorts of errors extremely cumbersome to debug if you're not aware of it. Instead, there should be a traceback to an AttributeError when getting self.bar in this example.

Branch: main @ 42c7483

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant