Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 856
Barak Adorian Avatar asked Jul 27 '17 06:07

Barak Adorian


2 Answers

Probably some custom class of yours has a bad __repr__ or __str__ in it and the debugger is unable to print it.

You can probably use a shell at that point to know which elements are actually inside such a dict or list (and see which object has the faulty __repr__ or __str__).

like image 166
Fabio Zadrozny Avatar answered Sep 20 '22 21:09

Fabio Zadrozny


It turned out the problem is due to usage of rpyc.py: The process I was debugging was called through rpyc and while I was debugging it, the calling process received a timeout on the rpyc connection. I think that this caused variables, passed through rpc to lose integrity so the debugger couldn't present them correctly.

The solution was to downgrade rpyc.py to version 3.3.0 (I was on 3.4.2). My colleague, Nurit Izraelov, correctly suggested the rpyc.py version may be the blame.

Thanks all!

like image 41
Barak Adorian Avatar answered Sep 22 '22 21:09

Barak Adorian