Skip to content

Commit c033c82

Browse files
Python code being generated sensibly.
1 parent 0ae9f64 commit c033c82

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

bind/gen_func.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,13 @@ if __err != nil {
381381
}
382382

383383
// Call upstream method and collect returns.
384-
g.pywrap.Printf(fmt.Sprintf("%s := %s", strings.Join(retvars, ", "), pyFuncCall))
384+
g.pywrap.Printf(fmt.Sprintf("%s := %s\n", strings.Join(retvars, ", "), pyFuncCall))
385385

386386
// ReMap handle returns from pyFuncCall.
387387
for i := 0; i < npyres; i++ {
388388
if res[i].sym.hasHandle() {
389389
cvnm := res[i].sym.pyPkgId(g.pkg.pkg)
390-
g.pywrap.Printf("ret%d = %s(handle=_ret%d)", cvnm, i, i)
390+
g.pywrap.Printf("ret%d = %s(handle=_ret%d)\n", i, cvnm, i)
391391
retvars[i] = "ret" + strconv.Itoa(i)
392392
}
393393
}
@@ -397,7 +397,7 @@ if __err != nil {
397397
g.pywrap.Printf(pyFuncCall)
398398
}
399399

400-
g.pywrap.Printf("\n")
400+
g.pywrap.Printf("\n\n")
401401
g.pywrap.Outdent()
402402

403403
goFuncCall := ""
@@ -460,7 +460,7 @@ if __err != nil {
460460
} else {
461461
g.gofile.Printf("if __err != nil {\n")
462462
g.gofile.Indent()
463-
g.gofile.Printf("estr := C.CString(__err.Error())// NOTE: leaked string\n") // NOTE: leaked string
463+
g.gofile.Printf("estr := C.CString(__err.Error())\n") // NOTE: freed string
464464
g.gofile.Printf("C.PyErr_SetString(C.PyExc_RuntimeError, estr)\n")
465465
g.gofile.Printf("C.free(unsafe.Pointer(estr))\n") // python should have converted, safe
466466
g.gofile.Outdent()

bind/package.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ func (p *Package) getDoc(parent string, o types.Object) string {
246246
paramString := strings.Join(params, ", ")
247247
resultString := strings.Join(results, ", ")
248248

249+
if len(results) > 1 {
250+
resultString = "(" + resultString + ")"
251+
}
252+
249253
//FIXME(sbinet): add receiver for methods?
250254
docSig := fmt.Sprintf("%s(%s) %s", o.Name(), paramString, resultString)
251255

0 commit comments

Comments
 (0)