diff options
author | Armin Rigo <arigo@tunes.org> | 2020-01-05 14:16:39 +0100 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2020-01-05 14:16:39 +0100 |
commit | fb724ca980f23cc6aa84d036f255a52df2d2248e (patch) | |
tree | 3e0e3f7b7bbcb637cc2ab9813d3a223113095b3f /lib_pypy/cffi | |
parent | issue 3141 part 2: use Py_TYPE(op) instead of (ob)->ob_type (diff) | |
download | pypy-fb724ca980f23cc6aa84d036f255a52df2d2248e.tar.gz pypy-fb724ca980f23cc6aa84d036f255a52df2d2248e.tar.bz2 pypy-fb724ca980f23cc6aa84d036f255a52df2d2248e.zip |
update to cffi/ba124ec241c1
Diffstat (limited to 'lib_pypy/cffi')
-rw-r--r-- | lib_pypy/cffi/api.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py index 32fe620898..999a8aefc4 100644 --- a/lib_pypy/cffi/api.py +++ b/lib_pypy/cffi/api.py @@ -141,7 +141,11 @@ class FFI(object): linked to a particular library, just like C headers; in the library we only look for the actual (untyped) symbols. """ - assert isinstance(name, basestring) or name is None + if not (isinstance(name, basestring) or + name is None or + isinstance(name, self.CData)): + raise TypeError("dlopen(name): name must be a file name, None, " + "or an already-opened 'void *' handle") with self._lock: lib, function_cache = _make_ffi_library(self, name, flags) self._function_caches.append(function_cache) @@ -799,9 +803,9 @@ class FFI(object): def _load_backend_lib(backend, name, flags): import os - if name is None: - if sys.platform != "win32": - return backend.load_library(None, flags) + if not isinstance(name, basestring): + if sys.platform != "win32" or name is not None: + return backend.load_library(name, flags) name = "c" # Windows: load_library(None) fails, but this works # on Python 2 (backward compatibility hack only) first_error = None @@ -935,7 +939,7 @@ def _make_ffi_library(ffi, libname, flags): backendlib.close_lib() self.__dict__.clear() # - if libname is not None: + if isinstance(libname, basestring): try: if not isinstance(libname, str): # unicode, on Python 2 libname = libname.encode('utf-8') |