Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r88146:f59244e00341 Date: 2016-11-05 15:41 +0100 http://bitbucket.org/pypy/pypy/changeset/f59244e00341/
Log: Issue #2428: Fix for an issue with ctypes (showing up as platform.uname() on recent Windows) diff --git a/pypy/module/_rawffi/alt/interp_funcptr.py b/pypy/module/_rawffi/alt/interp_funcptr.py --- a/pypy/module/_rawffi/alt/interp_funcptr.py +++ b/pypy/module/_rawffi/alt/interp_funcptr.py @@ -339,6 +339,9 @@ "No symbol %s found in library %s", name, self.name) return space.wrap(address_as_uint) + def getidentifier(self, space): + return space.wrap(self.cdll.getidentifier()) + @unwrap_spec(name='str_or_None', mode=int) def descr_new_cdll(space, w_type, name, mode=-1): return space.wrap(W_CDLL(space, name, mode)) @@ -349,6 +352,8 @@ __new__ = interp2app(descr_new_cdll), getfunc = interp2app(W_CDLL.getfunc), getaddressindll = interp2app(W_CDLL.getaddressindll), + __int__ = interp2app(W_CDLL.getidentifier), + __long__ = interp2app(W_CDLL.getidentifier), ) class W_WinDLL(W_CDLL): diff --git a/pypy/module/_rawffi/alt/test/test_funcptr.py b/pypy/module/_rawffi/alt/test/test_funcptr.py --- a/pypy/module/_rawffi/alt/test/test_funcptr.py +++ b/pypy/module/_rawffi/alt/test/test_funcptr.py @@ -643,3 +643,11 @@ f_name = libfoo.getfunc('AAA_first_ordinal_function', [], types.sint) f_ordinal = libfoo.getfunc(1, [], types.sint) assert f_name.getaddr() == f_ordinal.getaddr() + + def test_cdll_as_integer(self): + import _rawffi + from _rawffi.alt import CDLL + libfoo = CDLL(self.libfoo_name) + A = _rawffi.Array('i') + a = A(1, autofree=True) + a[0] = libfoo # should cast libfoo to int/long automatically diff --git a/rpython/rlib/libffi.py b/rpython/rlib/libffi.py --- a/rpython/rlib/libffi.py +++ b/rpython/rlib/libffi.py @@ -457,6 +457,9 @@ def getaddressindll(self, name): return dlsym(self.lib, name) + def getidentifier(self): + return rffi.cast(lltype.Unsigned, self.lib) + if os.name == 'nt': class WinDLL(CDLL): def getpointer(self, name, argtypes, restype, flags=FUNCFLAG_STDCALL): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit