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

Cannot pass Integer type to CallFunction #120

Open
@hedongho

Description

@hedongho

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy