Author: Armin Rigo <ar...@tunes.org> Branch: cffi-1.0 Changeset: r1969:861f9ef06179 Date: 2015-05-11 11:53 +0200 http://bitbucket.org/cffi/cffi/changeset/861f9ef06179/
Log: A case where raising NotImplementedError is more appropriate than just AttributeError diff --git a/cffi/api.py b/cffi/api.py --- a/cffi/api.py +++ b/cffi/api.py @@ -583,6 +583,11 @@ if name in library.__dict__: return # + key = 'constant ' + name + if key in ffi._parser._declarations: + raise NotImplementedError("fetching a non-integer constant " + "after dlopen()") + # raise AttributeError(name) # def make_accessor(name): diff --git a/testing/test_function.py b/testing/test_function.py --- a/testing/test_function.py +++ b/testing/test_function.py @@ -101,6 +101,17 @@ x = m.cos(1.23) assert x == math.cos(1.23) + def test_dlopen_constant(self): + ffi = FFI(backend=self.Backend()) + ffi.cdef(""" + #define FOOBAR 42 + static const float baz = 42.5; /* not visible */ + double sin(double x); + """) + m = ffi.dlopen(lib_m) + assert m.FOOBAR == 42 + py.test.raises(NotImplementedError, "m.baz") + def test_tlsalloc(self): if sys.platform != 'win32': py.test.skip("win32 only") _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit