Instantiating Python objects from C - segfault on `type(obj)`, `__class__` attribute missing

Yes, don’t look at slot_tp_call, look at tp_call.

It should be enough to call type->tp_new and then not call your type->tp_init and instead do the initialization in a different method that directly receives the file handle.

1 Like