Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Cannot pass Integer type to CallFunction #120

Open
hedongho opened this issue Aug 9, 2022 · 0 comments
Open

Cannot pass Integer type to CallFunction #120

hedongho opened this issue Aug 9, 2022 · 0 comments

Comments

@hedongho
Copy link

hedongho commented Aug 9, 2022

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/[email protected]/object.go:377 +0x89
github.com/sbinet/go-python.(*PyObject).CallFunction(0x4ae0f3?, {0xc00004cf60?, 0x1, 0x1})
        /usr/local/gopath/pkg/mod/github.com/sbinet/[email protected]/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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant