From be74c37022bf4f103e48e7f2ddb7747b4830b937 Mon Sep 17 00:00:00 2001 From: Sebastien Binet Date: Wed, 12 Aug 2015 11:44:27 +0200 Subject: [PATCH] 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 --- gopy.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gopy.py b/gopy.py index c254bfe..1e95079 100644 --- a/gopy.py +++ b/gopy.py @@ -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])