[pypy-issue] Issue #2694: [patch] ctypes.CDLL: implement handle argument (pypy/pypy)

David Naylor issues-reply at bitbucket.org
Wed Nov 1 14:11:39 EDT 2017

New issue 2694: [patch] ctypes.CDLL: implement handle argument

David Naylor:

PyPy internally didn't implement the handle argument (or CDLL._handle property).  The oversight was likely due to CPython reaching into the internals of the CDLL library from the _ctypes.so code.  

The attached patch implements handle by extending RPython's libffi.CDLL to use the handle if provided (otherwise using dlopen to get the handle).  In turn _rawffi.alt.CDLL is extended to pass handle through from ctypes to libffi.  

A default value of 0 is used (instead of None) as 0 is the equivalent of NULL and is the error condition from dlopen.  

The attached patch fixes both PyPy and PyPy3.  

This fixes the rtld_default_lib code in ll2types on FreeBSD.

More information about the pypy-issue mailing list