Author: Armin Rigo <[email protected]>
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
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit