PyCharm debugger doesn't show objects' content: "Unable to get repr for <type 'list>"

Viewed 5181

Debugging with PyCharm (happens on multiple versions) I'm unable to correctly view some lists and dictionaries (other are presented correctly). In the view window the object's name is presented with the message: {list} Unable to get repr for <type 'list> or {dict} Unable to get repr for <type 'dict'>

An update: In one of my attempts, I received the following message from the debugger (presented instead of the value of one of the list variable):

Unable to display children:Error resolving variables Traceback (most recent call last): File "/Applications/PyCharm CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 1004, in do_it _typeName, valDict = pydevd_vars.resolve_compound_variable(self.thread_id, self.frame_id, self.scope, self.attributes) TypeError: 'NoneType' object is not iterable

I'll appreciate any idea as for what may cause this behavior?

Thanks!

4 Answers

It happened to me sometimes and what caused the behaviour was that some MyClass triggered an exception on its str method.

In such a case, PyCharm debugger only showed

some_object = {MyClass} Unable to get repr for <class 'my_app.models.MyClass'>

So what I did to confirm the origin was to watch repr(some_object) in the Watches section of the debugger. And there it gave me an explicit error message:

{TypeError}%d format: a number is required, not NoneType

Which helped me trace back to the origin.

I appreciate this is not a generic answer, but just a complement to Fabio's.

Extending the scope of the problem rather than adding an answer - all the other suggestions are what I do normally to get this working.

Could it be a race condition?

For me it appears to be something weird. In the Variables pane I can see correct representation for theObject, repr(theObject) and even [theObject] but if I set a variable in my code thus a = theObject or b = [theObject] then I get the "Unable to get repr for <class 'list'>" message.

theObject in this case is an instance of a subclassed D lang struct wrapped with autowrap.

Related