C API PyObject_GetAttrString returns <getset_descriptor> not the object I expected
Barry Scott schrieb am 10.02.19 um 13:08:
> After calling PyObject_GetAttrString() I expected to get a PyObject string
> back but I found that I had been given a <getset_description> instead.
> (gdb) p *args_o
> $4 = <getset_descriptor at remote 0x7fffea87c7e0>
> What is going on and how do I get from the <getset_descriptor> to the object I
Phil is right about the function itself, but my guess is that you called
GetAttr() on a class instead of an instance. Read up on Python descriptors
to understand what difference that makes.
Basically, you got something like a property object back, but not the value
that the property maintaines. If you look up the attribute on the instance,
the property (or descriptor) will hand it to you. The same applies to
method lookups and other special attributes that may also be implemented as
Also take a look at Cython, which is designed to keep users from having to
learn all these things and instead lets you do them in Python.