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

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!

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!

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.

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__).

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

Cannot read property 'findElementsOverride' of undefined

Protractor/jamine error message:
Failed: Cannot read property 'findElementsOverride' of undefined
any clue on whats causing this error message?
More details would have helped.At-least what caused the error:)
But I have faced this issue before and you will see this when using isElementPresent() in scenarios like below
expect(body.isElementPresent()).toBeTruthy();
The problem is that isElementPresent() is checks based on subLocator and doesnt accept null as argument
The docs state the proper way of using it
This checks whether the element identified by the subLocator is
present, rather than the current element finder
element(by.css('#abc')).isElementPresent(by.css('#def')).

Why is the (PyQt5) QWidget not being added to the QBoxLayout

Right so essentially I am creating a user interface and have attempted to add a QtWidgets.QLineEdit to a QVBoxLayout as well as a QtWidgets.QLabel to a different QVBoxLayout. Unfortunately it is not working and throwing up an error:
in build_gui_adddata_device
self.labellayout.addWidget(self.labelsupplierid)
TypeError: QBoxLayout.addwidget(QWidget; int stretch=0, Qt.Alignment alignment=0): first argument of unbound = method must have type QBoxLayout
I have defined labellayout as thus:
print("e")
self.labellayout = QtWidgets.QVBoxLayout
"e" was printed, which is how I know that there is no issue with the definition of the layout itself.
Just for reference this is the QtWidget I was trying to add:
print("f")
self.labelsupplierid = QtWidgets.QLabel("Supplier ID: ")
Again "f" was printed
This is the line that is causing the problem:
print("i")
self.labellayout.addWidget(self.labelsupplierid)
I don't understand why my code isn't working, I am honestly perplexed. My syntax seems to be correct and I have made other build_gui functions that have executed exactly the same type of code (with different widgets, might I add) that have been successful.
Please can someone enlighten me. Many Thanks.

Check if property exists in object

I spent a long time now trying to figure this myself with the help of other questions but failed so I REALLY need to ask this again
I have the following object in ruby
(...)
:follow_request_sent:
:notifications:
:coordinates:
:place:
:contributors:
:favorite_count: 0
:entities:
:hashtags:
- :text:
:indices:
(...)
This is object X. What I want to do is check if x.place exists. I've tried barely EVERYTHING. any, ?, include?, with [hash], defined?, (...) but it ALWAYS throws an error "undefined method" when trying to access the property, whether it exists or not. It NEVER works and I don't understand why. This is twitter API btw. Does anyone imagine why? Please do not point me to another answers because basically they all failed.
If you want to see if there is such a method:
x.respond_to?(:place)
If you want to see if there is an instance variable:
x.instance_variable_defined?(:#place)

How can I tell where my XCode output originates from?

For example, in my console, I have output such as :
2012-11-29 21:25:40.696 Program[31053:707] -[Staff Shifts]: unrecognized selector sent to instance 0x107d6fdd0
2012-11-29 21:25:40.697 Program[31053:707] Exception detected while handling key input.
I was wondering if there's an easy way to find out where this is from?
The debug console can only tell you so much. According to the error, you are trying to access a selector (possibly) within the class Staff that isn't recognized by the instance of that class.
You could, however, use this bit of information to set a breakpoint within that class and step over methods until the exception reoccurs. Then you could set a breakpoint at that method and step into it until you find the problem.
You could also use gdb po at runtime to check for nil/unexpected objects.
The [Staff Shifts] might indicate that you have a class named [Staff Shifts] in your code that is causing the error. An unrecognized selector means that you have the following:
selector: #selector(FunctionName:)
But the function FunctionName: doesn't exist...

Splunk-client (with Nokogiri) giving Undefined Namespace Prefix

I'm using splunk-client to extract results from splunk. Here's the code:
query = "sourcetype=collection #{order_id}"
search = #splunk_client.search(query)
search.wait
The search is happening fine, and it seems like I'm doing everything according to the example (https://github.com/cbrito/splunk-client), but I get this error on the 'search.wait' line:
Undefined namespace prefix: //s:key[#name='isDone']
Any ideas what could be going wrong? Running these commands in irb works fine. Is there some sort of blocking issue?
There is currently very little error checking which occurs within the gem itself. The reason for the error is that wait looks for the status of the isDone key to change to true.
Since your credentials were not properly setup in the first place, the gem creates a search object with an invalid session. The search does not initially fail, because enough response came back from Splunk that Nokogiri processes it into an object without a Splunk search sid.
In the future I should likely raise an exception if a proper sid is not returned to avoid confusion.
Source: I wrote the gem.
I found out the issue -- the splunk client wasn't authenticating properly, and so search was actually a broken SplunkJob object (with a nil username and authentication key). It's strange that there was no error raised until the wait command, but upon inspecting the search object, one of the fields stated that the object was malformed.

Resources