diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-11 05:06:07 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-11 05:06:07 +0000 |
commit | ee6e9789420f9e81a34a3df7afcaf3bd7ac0c7d1 (patch) | |
tree | 64f8c90740adbe25c30379d6567fd2acafcbd2dd /cffi/api.py | |
parent | cfef9f25f39bdaf362b7cbccc51720e3a0ed3d35 (diff) | |
parent | 046d35db06dec26c759b92b7d8de38a979d84c0b (diff) | |
download | cffi-android13-mainline-media-swcodec-release.tar.gz |
Snap for 8570526 from 046d35db06dec26c759b92b7d8de38a979d84c0b to mainline-media-swcodec-releaseaml_swc_331911000aml_swc_331712000aml_swc_331612000aml_swc_331511000aml_swc_331410000aml_swc_331318000aml_swc_331116000aml_swc_331012020android13-mainline-media-swcodec-release
Change-Id: I25ab4fac7810181b81cdda451d2aa7121266db70
Diffstat (limited to 'cffi/api.py')
-rw-r--r-- | cffi/api.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/cffi/api.py b/cffi/api.py index 32fe620..999a8ae 100644 --- a/cffi/api.py +++ b/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') |