[pypy-commit] pypy cffi-1.0: Add a test and fix
arigo
noreply at buildbot.pypy.org
Mon May 18 12:42:20 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r77372:3bafa1b4e46a
Date: 2015-05-18 12:42 +0200
http://bitbucket.org/pypy/pypy/changeset/3bafa1b4e46a/
Log: Add a test and fix
diff --git a/pypy/module/_cffi_backend/cdlopen.py b/pypy/module/_cffi_backend/cdlopen.py
--- a/pypy/module/_cffi_backend/cdlopen.py
+++ b/pypy/module/_cffi_backend/cdlopen.py
@@ -31,6 +31,9 @@
dlclose(self.libhandle)
def cdlopen_fetch(self, name):
+ if not self.libhandle:
+ raise oefmt(self.ffi.w_FFIError, "library '%s' has been closed",
+ self.libname)
try:
cdata = dlsym(self.libhandle, name)
except KeyError:
diff --git a/pypy/module/_cffi_backend/test/test_re_python.py b/pypy/module/_cffi_backend/test/test_re_python.py
--- a/pypy/module/_cffi_backend/test/test_re_python.py
+++ b/pypy/module/_cffi_backend/test/test_re_python.py
@@ -105,6 +105,9 @@
e = raises(ffi.error, ffi.dlclose, lib)
assert str(e.value) == (
"library '%s' is already closed" % (self.extmod,))
+ e = raises(ffi.error, getattr, lib, 'add42')
+ assert str(e.value) == (
+ "library '%s' has been closed" % (self.extmod,))
def test_constant_via_lib(self):
from re_python_pysrc import ffi
More information about the pypy-commit
mailing list