import pdir
class A():
__slots__ = ['a']
a = A()
pdir(a)
Error message:
Traceback (most recent call last):
File "/export/home/weitangli/GitClone/pdir2/pdir/api.py", line 165, in __getattr_wrapper
return get_dict_attr(self.obj, name)
File "/export/home/weitangli/GitClone/pdir2/pdir/utils.py", line 4, in get_dict_attr
if attr in obj.__dict__:
AttributeError: 'A' object has no attribute '__dict__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 7, in <module>
pdir(a)
File "/export/home/weitangli/GitClone/pdir2/pdir/api.py", line 43, in __init__
attr = self.__getattr_wrapper(name)
File "/export/home/weitangli/GitClone/pdir2/pdir/api.py", line 167, in __getattr_wrapper
return getattr(self.obj, name)
AttributeError: a
This is because even though 'a' is not defined for a, it is still in its __dir__() due to the mechanism of __slots__:
Code to reproduce the error:
Error message:
This is because even though 'a' is not defined for
a
, it is still in its__dir__()
due to the mechanism of__slots__
: