Bug description:
Zero-argument super() raises TypeError in a method of a class decorated with ctypes.util.struct:
from ctypes import c_int
from ctypes.util import struct
@struct
class Point:
x: c_int
y: c_int
def __init__(self, x=0, y=0):
super().__init__(x, y)
print(Point(1, 2).x)
TypeError: super(type, obj): obj (instance of Point) is not an instance or subtype of type (Point).
The same method on a plain Structure subclass works. __class__ in such a method also refers to the original class instead of the one the decorator returns.
Expected: super() and __class__ refer to the class returned by @struct, and the example prints 1.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug description:
Zero-argument
super()raisesTypeErrorin a method of a class decorated withctypes.util.struct:The same method on a plain
Structuresubclass works.__class__in such a method also refers to the original class instead of the one the decorator returns.Expected:
super()and__class__refer to the class returned by@struct, and the example prints1.CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
super()inctypes.util.structmethods #158419