Skip to content

Commit a43ed6c

Browse files
committed
RFC: treat PyTypeObject as an opaque struct for Limited API compliance
1 parent dc15c42 commit a43ed6c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

extension/wrapper.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ Satrec_twoline2rv(PyTypeObject *cls, PyObject *args)
121121
line2[68] = '\0';
122122

123123
/* Allocate the new object. */
124-
SatrecObject *self = (SatrecObject*) cls->tp_alloc(cls, 0);
124+
allocfunc alloc_func = (allocfunc)PyType_GetSlot(cls, Py_tp_alloc);
125+
SatrecObject *self = (SatrecObject*)alloc_func(cls, 0);
125126
if (!self)
126127
return NULL;
127128

@@ -510,7 +511,9 @@ SatrecArray_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
510511
if (length == -1)
511512
return NULL;
512513

513-
return type->tp_alloc(type, length);
514+
allocfunc alloc_func = (allocfunc)PyType_GetSlot(type, Py_tp_alloc);
515+
PyObject *ret = alloc_func(type, length);
516+
return ret;
514517
}
515518

516519

0 commit comments

Comments
 (0)