Skip to content

Commit d0cfd28

Browse files
committed
bind: function should return zero value on error (refs #254)
1 parent ac5c077 commit d0cfd28

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

bind/gen_func.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,15 @@ if __err != nil {
420420
g.gofile.Printf("return estr\n") // NOTE: leaked string
421421
} else {
422422
g.gofile.Printf("C.free(unsafe.Pointer(estr))\n") // python should have converted, safe
423+
ret := res[0]
424+
if ret.sym.zval == "" {
425+
fmt.Printf("gopy: programmer error: empty zval zero value in symbol: %v\n", ret.sym)
426+
}
427+
if ret.sym.go2py != "" {
428+
g.gofile.Printf("return %s(%s)%s\n", ret.sym.go2py, ret.sym.zval, ret.sym.go2pyParenEx)
429+
} else {
430+
g.gofile.Printf("return %s\n", ret.sym.zval)
431+
}
423432
}
424433
g.gofile.Outdent()
425434
g.gofile.Printf("}\n")

0 commit comments

Comments
 (0)