Skip to content

TypeError on use of super() in ctypes.c_uint64 subclass #147987

@rmorshea

Description

@rmorshea

Bug report

Bug description:

When subclassing ctypes.c_uint64, if you use super() in any method definitions you get a TypeError upon defining the class similar to the following:

import ctypes
class MyClass(ctypes.c_uint64):
    def f(self):
        super()
TypeError: __class__ set to <class '__main__.MyClass'> defining 'MyClass' as <class '__main__.MyClass'>

This does not raise an error if subclassing other ctypes (e.g. c_uint8):

import ctypes
class MyClass(ctypes.c_uint8):  # ok
    def f(self):
        super()

It's also ok to subclass c_uint64 if you don't use super:

import ctypes
class MyClass(ctypes.c_uint64):  # ok
    def f(self):
        pass

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions