Bug in object display in debugger?

class TMerge:

    def __init__(self, t1, t2):
        self.t1 = t1
        self.t2 = t2

    def __call__(self, object):
        return self.t1

tm1 = TMerge(3, lambda x: x + 2)
tm2 = TMerge(lambda x: x + 5, 6)
x = 1

Make a breakpoint on the "tm1" line, step through. Notice that tm1 is shown with a single instance variable (t1), and tm2 is shown with a single instance variable (t2). The debugger seems to be confused because of the __call__ method, and refuses to show the instance variable with the lambda value.

I just spent an hour wondering what I was doing wrong!
8 comments
Comment actions Permalink
Can anyone confirm if this is considered a bug? If so, is there some place online where I should report it?

Thanks!
0
Comment actions Permalink
Hi Des!
Sorry for delayed response.
That is definitely a bug. I've created an issue http://youtrack.jetbrains.com/issue/PY-8138
0
Comment actions Permalink
Hi Des!
I've looked at this more closely and can say that this is not a bug indeed. PyCharm debugger filters out all function fields from variables. To watch detailed object content I recommend using debug console where you can execute any commands like dir(tm1) while you are standing at a breakpoint.
0
Comment actions Permalink
Hi Dmitry!

Please re-consider this issue. When I look at any object in the debugger, I expect to see every field I have defined on that object.

If I use any Python object with a field containing a lambda value, that field totally disappears in the Pycharm debugger. This makes Pycharm debugger most confusing for code that passes around functions, i.e. for any kind of functional programming. I understand you may not want to show all instance methods, but Python has plenty of ways to distinguish bound method, unbound method, and function-lambdas.

class A(object):
    def f(self): pass


f = A().f
f

<bound method A.f of <__main__.A object at 0x2c8b90>>
a = A()
a.g = lambda p: p+2
a.g

<function <lambda> at 0x2c6770>
a.f

<bound method A.f of <__main__.A object at 0x2c8c10>>
>>> A.f

<unbound method A.f>


Please re-open this as a bug! Using dir(x) is a very painful alternative! Thanks!!
0
Comment actions Permalink
This issue is still causing me a lot of pain. If anyone uses a style of even partial functional programming (passing around functions, lambdas, etc.) they would ABSOLUTELY HAVE to see these in the debugger. For fields to totally disappear in the debugger just because they contain some functional object makes no sense.

Please, is there any plan to fix this? Our project uses this style quite heavily.
0
Comment actions Permalink
Even just showing the value would be a big improvement. A logical next step (for a functional value) would be to allow easy navigation to the source code that it came from (Python even has built-in ways to do this that work in most cases, like in the built-in inspect module).
0
Comment actions Permalink

This is still an issue and highly frustrating if you're unaware of this fact. Please JetBrains could you please reconsider and add this feature to the debugger?

PyCharm is a great product. Please make it even more great.

Kind regards.

Erik

0
Comment actions Permalink

I think I'm running into a similar problem as the folks above. I'm debugging objects and wondering what methods they contain. For an hour or so I was very confused how methods were being called that didn't appear in the debugger, before finally realizing the debugger doesn't show bound methods. Can a feature be added to the debugger that shows bound methods? This would be equivalent to inspect.getmembers which lists all the methods.

 

For reference I am using Pycharm 2016.3.2 Community Edition on Arch

0

Please sign in to leave a comment.