@@ -38,7 +38,8 @@ var WindowsOS = false
38
38
39
39
// for all preambles: 1 = name of package (outname), 2 = cmdstr
40
40
41
- // 3 = libcfg, 4 = GoHandle, 5 = CGoHandle, 6 = all imports, 7 = mainstr, 8 = exe pre C, 9 = exe pre go
41
+ // 3 = libcfg, 4 = GoHandle, 5 = CGoHandle, 6 = all imports, 7 = goerr2pyex Package path, 8 = mainstr,
42
+ // 9 = exe pre C, 10 = exe pre go
42
43
const (
43
44
goPreamble = `/*
44
45
cgo stubs for package %[1]s.
@@ -85,17 +86,19 @@ static inline void gopy_err_handle() {
85
86
PyErr_Print();
86
87
}
87
88
}
88
- %[8 ]s
89
+ %[9 ]s
89
90
*/
90
91
import "C"
91
92
import (
92
93
"github.com/go-python/gopy/gopyh" // handler
94
+ "%[7]s" // Error Translator
95
+
93
96
%[6]s
94
97
)
95
98
96
99
// main doesn't do anything in lib / pkg mode, but is essential for exe mode
97
100
func main() {
98
- %[7 ]s
101
+ %[8 ]s
99
102
}
100
103
101
104
// initialization functions -- can be called from python after library is loaded
@@ -104,7 +107,7 @@ func main() {
104
107
105
108
//export GoPyInit
106
109
func GoPyInit() {
107
- %[7 ]s
110
+ %[8 ]s
108
111
}
109
112
110
113
// type for the handle -- int64 for speed (can switch to string)
@@ -164,7 +167,7 @@ func complex128PyToGo(o *C.PyObject) complex128 {
164
167
return complex(float64(v.real), float64(v.imag))
165
168
}
166
169
167
- %[9 ]s
170
+ %[10 ]s
168
171
`
169
172
170
173
goExePreambleC = `
@@ -430,6 +433,9 @@ var NoWarn = false
430
433
// NoMake turns off generation of Makefiles
431
434
var NoMake = false
432
435
436
+ // NoPyExceptions turns off generation of Python Exceptions
437
+ var NoPyExceptions = false
438
+
433
439
// GenPyBind generates a .go file, build.py file to enable pybindgen to create python bindings,
434
440
// and wrapper .py file(s) that are loaded as the interface to the package with shadow
435
441
// python-side classes
@@ -603,7 +609,7 @@ func (g *pyGen) genGoPreamble() {
603
609
exeprego = goExePreambleGo
604
610
}
605
611
g .gofile .Printf (goPreamble , g .cfg .Name , g .cfg .Cmd , libcfg , GoHandle , CGoHandle ,
606
- pkgimport , g .cfg .Main , exeprec , exeprego )
612
+ pkgimport , g .cfg .ModPathGoErr2PyEx , g . cfg . Main , exeprec , exeprego )
607
613
g .gofile .Printf ("\n // --- generated code for package: %[1]s below: ---\n \n " , g .cfg .Name )
608
614
}
609
615
0 commit comments