@@ -38,7 +38,8 @@ var WindowsOS = false
3838
3939// for all preambles: 1 = name of package (outname), 2 = cmdstr
4040
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
4243const (
4344 goPreamble = `/*
4445cgo stubs for package %[1]s.
@@ -85,17 +86,19 @@ static inline void gopy_err_handle() {
8586 PyErr_Print();
8687 }
8788}
88- %[8 ]s
89+ %[9 ]s
8990*/
9091import "C"
9192import (
9293 "github.com/go-python/gopy/gopyh" // handler
94+ "%[7]s" // Error Translator
95+
9396 %[6]s
9497)
9598
9699// main doesn't do anything in lib / pkg mode, but is essential for exe mode
97100func main() {
98- %[7 ]s
101+ %[8 ]s
99102}
100103
101104// initialization functions -- can be called from python after library is loaded
@@ -104,7 +107,7 @@ func main() {
104107
105108//export GoPyInit
106109func GoPyInit() {
107- %[7 ]s
110+ %[8 ]s
108111}
109112
110113// type for the handle -- int64 for speed (can switch to string)
@@ -164,7 +167,7 @@ func complex128PyToGo(o *C.PyObject) complex128 {
164167 return complex(float64(v.real), float64(v.imag))
165168}
166169
167- %[9 ]s
170+ %[10 ]s
168171`
169172
170173 goExePreambleC = `
@@ -430,6 +433,9 @@ var NoWarn = false
430433// NoMake turns off generation of Makefiles
431434var NoMake = false
432435
436+ // NoPyExceptions turns off generation of Python Exceptions
437+ var NoPyExceptions = false
438+
433439// GenPyBind generates a .go file, build.py file to enable pybindgen to create python bindings,
434440// and wrapper .py file(s) that are loaded as the interface to the package with shadow
435441// python-side classes
@@ -603,7 +609,7 @@ func (g *pyGen) genGoPreamble() {
603609 exeprego = goExePreambleGo
604610 }
605611 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 )
607613 g .gofile .Printf ("\n // --- generated code for package: %[1]s below: ---\n \n " , g .cfg .Name )
608614}
609615
0 commit comments