Skip to content

Commit 2cb06f8

Browse files
__err was getting reused in a way which declarations difficult. Fixed.
1 parent 14d81b4 commit 2cb06f8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bind/gen_func.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ if __err != nil {
448448
retvals[i] = "cret" + strconv.Itoa(i)
449449
}
450450
if fsym.haserr {
451-
retvals[nres-1] = "__err"
451+
retvals[nres-1] = "__err_ret"
452452
}
453453

454454
// Call upstream method and collect returns.
@@ -470,19 +470,19 @@ if __err != nil {
470470
if rvHasErr {
471471
retvals[npyres-1] = "estr" // NOTE: leaked string
472472
g.gofile.Printf("var estr C.CString\n")
473-
g.gofile.Printf("if __err != nil {\n")
473+
g.gofile.Printf("if __err_ret != nil {\n")
474474
g.gofile.Indent()
475-
g.gofile.Printf("estr = C.CString(__err.Error())// NOTE: leaked string\n") // NOTE: leaked string
475+
g.gofile.Printf("estr = C.CString(__err_ret.Error())// NOTE: leaked string\n") // NOTE: leaked string
476476
g.gofile.Outdent()
477477
g.gofile.Printf("} else {\n")
478478
g.gofile.Indent()
479479
g.gofile.Printf("estr = C.CString(\"\")// NOTE: leaked string\n") // NOTE: leaked string
480480
g.gofile.Outdent()
481481
g.gofile.Printf("}\n")
482482
} else {
483-
g.gofile.Printf("if __err != nil {\n")
483+
g.gofile.Printf("if __err_ret != nil {\n")
484484
g.gofile.Indent()
485-
g.gofile.Printf("estr := C.CString(__err.Error())\n") // NOTE: freed string
485+
g.gofile.Printf("estr := C.CString(__err_ret.Error())\n") // NOTE: freed string
486486
g.gofile.Printf("C.PyErr_SetString(C.PyExc_RuntimeError, estr)\n")
487487
g.gofile.Printf("C.free(unsafe.Pointer(estr))\n") // python should have converted, safe
488488
g.gofile.Outdent()

0 commit comments

Comments
 (0)