Open hedongho opened 1 year ago
the case is that when i use CallFunction to execute python module functions, and pass int type variable, it occur error like this:
[root@c7dev rootwd]# go build gptest/main.go [root@c7dev rootwd]# ./main panic: runtime error: cgo argument has Go pointer to Go pointer goroutine 1 [running]: github.com/sbinet/go-python.(*PyObject).CallFunction.func4(0xd0d510?, {0xc00004cf60?, 0x1, 0x0?}, 0xc00004ce48?, 0xc00004cef8) /usr/local/gopath/pkg/mod/github.com/sbinet/go-python@v0.1.0/object.go:377 +0x89 github.com/sbinet/go-python.(*PyObject).CallFunction(0x4ae0f3?, {0xc00004cf60?, 0x1, 0x1}) /usr/local/gopath/pkg/mod/github.com/sbinet/go-python@v0.1.0/object.go:377 +0x205 main.main() /root/rootwd/gptest/main.go:21 +0x66
here is my code:
package main import ( "github.com/sbinet/go-python" ) func init() { err := python.Initialize() if err != nil { panic(err.Error()) } } func main() { mod := python.PyImport_ImportModule("tpy.test") fobj := mod.GetAttrString("test") fobj.CallFunction("aaa") // ok fobj.CallFunction(1) // panic: runtime error: cgo argument has Go pointer to Go pointer }
python module file:
# tpy.test def test(data): print "xxxx", data
I'm not sure if i use it in a wrong way.
the case is that when i use CallFunction to execute python module functions, and pass int type variable, it occur error like this:
here is my code:
python module file:
I'm not sure if i use it in a wrong way.