Bob
Bob

Reputation: 5010

pycharm - how to trace hidden class method __get__

class Foo():
    def __init__(self):
        self.bar_ref = self.bar  # Allocation occurs here
        self.x = 0.1

    def bar(self, _):
        self.x *= 1.2

@wim said

The dotted attribute access self.bar is an invocation of descriptor __get__, creating a bound method.

How do I get Pycharm to show __get__ being executed when debugging?

Upvotes: 2

Views: 87

Answers (1)

user2357112
user2357112

Reputation: 282026

The relevant __get__ method is implemented in C; it's func_descr_get in Objects/funcobject.c. PyCharm does not support stepping into code written in C.

I believe you could step into this code with a Python debug build and the Cython GDB extension, or even with a Python debug build and regular GDB if you're okay with seeing everything from the raw C-level perspective, but you can't do it in PyCharm.

Upvotes: 3

Related Questions