This repository was archived by the owner on Mar 23, 2023. It is now read-only.
This repository was archived by the owner on Mar 23, 2023. It is now read-only.
Failed to import some python std libs(e.g. json) in python code and then called in go code #408
Open
Description
My python code is as below
def feature1(inputJsonString):
print inputJsonString
import json
import sys
print json.dumps(1)
return sys.version
and the go main code is as below
package main
import ... // I have imported all the package under the "$GOPATH/src/__python__" and thus "json" related libs should be imported
func main() {
f := grumpy.NewRootFrame()
mods, _ := grumpy.ImportModule(f, "feature1")
fmt.Printf("mods: %v\n", mods)
feature1, _ := grumpy.GetAttr(f, mods[0], grumpy.NewStr("feature1"), nil)
args := f.MakeArgs(1)
args[0] = grumpy.NewStr(`{"a": 1, "b": "I am string"}`).ToObject()
result, err := feature1.Call(f, args, nil)
fmt.Printf("result type: %v\n", reflect.TypeOf(result))
fmt.Printf("result: %v\n", result.String())
fmt.Printf("err: %v\n", err)
}
When I tried to run the go main code, and I got result like this
result: nil
err: TypeError('bad operand type for unary -: \'tuple\'',)
I found this error is raised from grumpy.ImportModule function in generated go code feature1.go but I am not clear how this error is raised. Also when I try to import some other python std libs like "sys", and it works fine.
My Golang version is go1.10.3 darwin/amd64
Metadata
Metadata
Assignees
Labels
No labels