go-python/gopy

Cannot get sample working under Go 1.6.x?

myitcv opened this issue · 6 comments

Apologies if I'm missing something blindingly obvious here, but I cannot get the command line example working under Go 1.6.x

Everything works fine under Go 1.5.3, but under Go 1.6.2 I see:

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GORACE=""
GOROOT="/home/myitcv/gos"
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
$ python
Python 2.7.10 (default, Jun 14 2015, 18:40:08)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hi
>>> hi.Hello("you")
panic: runtime error: cgo result has Go pointer

goroutine 17 [running, locked to thread]:
panic(0x7fbaac0da9a0, 0xc82007e1c0)
        /home/myitcv/gos/src/runtime/panic.go:481 +0x3ea
main._cgoexpwrap_1c71e8bfd213__cgopy_GoString.func1(0xc820040ee8)
        _/tmp/gopy-122143260/_obj/_cgo_gotypes.go:85 +0x68
main._cgoexpwrap_1c71e8bfd213__cgopy_GoString(0x7fbaadaa1b94, 0xc82007e181, 0x3)
        _/tmp/gopy-122143260/_obj/_cgo_gotypes.go:87 +0x85
Aborted (core dumped)

Happy to continue playing under Go 1.5.3 for now but any help much appreciated.

yes, unfortunately, gopy isn't Go-1.6 (>=1.6, actually) compliant.
you could run it with Go >=1.6 if you were to export GODEBUG="cgocheck=0" (that's not something to be done in production, though) as documented here:
https://golang.org/cmd/cgo/#hdr-Passing_pointers

I have been working off and on on rewriting some of the generated code to be compliant with the "new" cgo rules. the WIP code is there: https://github.com/go-python/gopy/tree/bind-seq
(but it's lacking a great deal of features wrt the master branch.)

I'll carve up time to get back to this during July-August.

Sorry about this.

Thanks @sbinet, appreciate the quick response

Might just be worth tweaking the README in the meantime?

Right. Will do when in front of a real keyboard :)

done: a4a4772

Any plan to add support for more recent Go versions? Thanks!

for old version, closing