// static inline PyObject *typeAlloc(PyObject *t, Py_ssize_t n) {// return ((PyTypeObject *)t)->tp_alloc((PyTypeObject *)t, n);// }import "C"
func (t *Type) Alloc(n int64) (Object, error) { ret := C.typeAlloc(c(t), C.Py_ssize_t(n)) // This line is causing the error return obj2ObjErr(ret)}
func c(obj Object) *C.PyObject { if obj == nil { return nil } return (*C.PyObject)(unsafe.Pointer(obj.Base()))}--- FAIL: TestMethod (0.03s)panic: runtime error: cgo result has Go pointer [recovered] panic: runtime error: cgo result has Go pointer
goroutine 5 [running]:panic(0x5b35a0, 0xc82000e7c0) /usr/lib/go/src/runtime/panic.go:464 +0x3e6testing.tRunner.func1(0xc82009c000) /usr/lib/go/src/testing/testing.go:467 +0x192panic(0x5b35a0, 0xc82000e7c0) /usr/lib/go/src/runtime/panic.go:426 +0x4e9 ??:0 +0x3agithub.com/limetext/gopy/lib._cgoexpwrap_14798609a186_goGenericAlloc(0x1846c20, 0x0, 0xc82000a360) ??:0 +0x6f ??:0 +0x42github.com/limetext/gopy/lib.(*Type).Alloc(0x1846c20, 0x0, 0x0, 0x0, 0x0, 0x0) /home/zoli/Code/go/src/github.com/limetext/gopy/lib/type.go:40 +0xd9github.com/limetext/gopy/lib.goClassNew(0x1846c20, 0x7fe0a4956048, 0x0, 0x45a420) /home/zoli/Code/go/src/github.com/limetext/gopy/lib/class.go:449 +0x35dgithub.com/limetext/gopy/lib._cgoexpwrap_14798609a186_goClassNew(0x1846c20, 0x7fe0a4956048, 0x0, 0x0) ??:0 +0x6egithub.com/limetext/gopy/lib._Cfunc_PyRun_StringFlags(0x186cff0, 0x100, 0x7fe0a48bcc08, 0x0, 0x0, 0x0) ??:0 +0x42github.com/limetext/gopy/lib.RunString(0x629ca0, 0x22, 0x2, 0x7fe0a499a598, 0x7fe0a48bcc08, 0x0, 0x0, 0x0, 0x0, 0x0, ...) /home/zoli/Code/go/src/github.com/limetext/gopy/lib/run.go:34 +0x209 /home/zoli/Code/go/src/github.com/limetext/gopy/lib/module_test.go:75 +0x82ftesting.tRunner(0xc82009c000, 0x8f1a08) /usr/lib/go/src/testing/testing.go:473 +0x98created by testing.RunTests /usr/lib/go/src/testing/testing.go:582 +0x892exit status 2FAIL github.com/limetext/gopy/lib 0.032s//export goGenericAllocfunc goGenericAlloc(t unsafe.Pointer, n C.Py_ssize_t) unsafe.Pointer { var obj *C.PyObject
typ := newType((*C.PyObject)(t)) size := uintptr(C.var_size(c(typ), n))
if typ.IsGc() { obj = goGcMalloc(size) } else { obj = goMalloc(size) }
if obj == nil { raise(MemoryError.ErrV(None)) return nil }
if typ.o.tp_flags&C.Py_TPFLAGS_HEAPTYPE != 0 { typ.Incref() }
if typ.o.tp_itemsize == 0 { C.GoPyObject_INIT(obj, c(typ)) } else { C.GoPyObject_INIT_VAR(obj, c(typ), n) }
if typ.IsGc() { C.GoPyObject_GC_Track(obj) }
return unsafe.Pointer(obj)}