Skip to content

Commit 603eba4

Browse files
Randall C. O'Reillysbinet
Randall C. O'Reilly
authored andcommitted
go.nil must be explicitly initialized in go.py -- just doing nil = GoClass() doesn't do it.
1 parent d39a3c4 commit 603eba4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ New features:
1717

1818
## Installation
1919

20-
Currently using [pybindgen](https://pybindgen.readthedocs.io/en/latest/tutorial/) to generate the low-level c-to-python bindings, but support for [cffi](https://cffi.readthedocs.io/en/latest/) should be relatively straightforward for those using PyPy instead of CPython (pybindgen should be significantly faster for CPython apparently).
20+
Currently using [pybindgen](https://pybindgen.readthedocs.io/en/latest/tutorial/) to generate the low-level c-to-python bindings, but support for [cffi](https://cffi.readthedocs.io/en/latest/) should be relatively straightforward for those using PyPy instead of CPython (pybindgen should be significantly faster for CPython apparently). You also need `goimports` to ensure the correct imports are included.
2121

2222
```sh
2323
$ python3 -m pip install pybindgen
24+
$ go get golang.org/x/tools/cmd/goimports
2425
$ go get github.com/go-python/gopy
2526
```
2627

27-
You will need `Go >= 1.5` (no reason not to use the most recent version).
28+
(This all assumes you have already installed [Go itself](https://golang.org/doc/install), and added `~/go/bin` to your `PATH`).
2829

2930
To [install python modules](https://packaging.python.org/tutorials/packaging-projects/), you will need the python install packages:
3031

bind/gen.go

+7
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@ class GoClass(object):
236236
# use go.nil for nil pointers
237237
nil = GoClass()
238238
239+
# need to explicitly initialize it
240+
def main():
241+
global nil
242+
nil = GoClass()
243+
244+
main()
245+
239246
def Init():
240247
"""calls the GoPyInit function, which runs the 'main' code string that was passed using -main arg to gopy"""
241248
_%[1]s.GoPyInit()

0 commit comments

Comments
 (0)