gopy: dont reload C-extension module

While waiting for #27 to be handled upstream, prevent users from crashing their
interpreter by not allowing to reload a C-extension module if already wrapped
and compiled.

Fixes #46.

Change-Id: Ic9624beae3061b286d09aca71882915923bd6298
This commit is contained in:
Sebastien Binet 2015-08-12 11:44:27 +02:00
parent 41f904d5cc
commit be74c37022
1 changed files with 4 additions and 0 deletions

View File

@ -30,6 +30,10 @@ def load(pkg, output=""):
print("gopy> inferring package name...")
pkg = check_output(["go", "list", pkg]).strip()
if pkg in sys.modules:
print("gopy> package '%s' already wrapped and loaded!" % (pkg,))
print("gopy> NOT recompiling it again (see issue #27)")
return sys.modules[pkg]
print("gopy> loading '%s'..." % pkg)
check_call(["gopy","bind", "-output=%s" % output, pkg])