Debug mode variabletree expansion not working when subclassing object and overwriting __getattribute__

Answered

When running the following code:

class Foo(object):
def __getattribute__(self, name):
attr = object.__getattribute__(self, name)
if hasattr(attr, '__call__'):
def newfunc(*args, **kwargs):
result = attr(*args, **kwargs)
return result
return newfunc
else:
return attr


bar = Foo()

in either Debug mode or in a Configuration which has "Run with python console" enabled PyCharm gives the following error in the console:

Traceback (most recent call last):
File "D:\programme\pycharm\PyCharm Community Edition 2019.1.2\plugins\python-ce\helpers\pydev\_pydevd_bundle\pydevd_thrift.py", line 160, in _get_type
if resolver.can_provide(type_object, type_name):
File "D:\programme\pycharm\PyCharm Community Edition 2019.1.2\plugins\python-ce\helpers\pydev\pydevd_plugins\extensions\types\pydevd_plugin_numpy_types.py", line 28, in can_provide
return nd_array is not None and issubclass(type_object, nd_array)
TypeError: issubclass() arg 1 must be a class

And it does not allow the expansion of the variable tree for any instance of the "Foo" class, instead returning the same error again. This occurs in python versions 3.6 - 3.8 (others not yet tested) as well as with both python and anaconda interpreters.

I am currently running the following version of PyCharm:

PyCharm 2020.2 (Community Edition)
Build #PC-202.6397.98, built on July 27, 2020
Runtime version: 11.0.7+10-b944.20 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep

Why does this occur? The functionality of the class is not disrupted by this change of the __getattribute__() method and it is strange that this is happening when checking if it actually is a class.

Should this be traceable to the change to the __getattribute__() method how would i need to change it (using the standard __getattribute__() is not a option sadly) to make sure the functionality of the variable tree is not disrupted?

0
3 comments

Hi,

I can reproduce it when running your code with "Run with python console" enabled, but can't reproduce it when debugging.

Could you describe how you reproduce it in more detail?

0
Avatar
Permanently deleted user

if you add these two lines (or anything else that results in a call made to that object):

bar.a = "foo"
print(bar.a)

and add a break point anywhere in the code it does give that same error.

0

Got it, thanks!

I filed a bug to our issue tracker https://youtrack.jetbrains.com/issue/PY-43902, please upvote and feel free to comment.

0

Please sign in to leave a comment.