diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-02-05 21:13:45 +0000 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-02-05 21:13:45 +0000 |
commit | 28fd3e15b9848fd7a0d1752e4728d2aad1848141 (patch) | |
tree | ba241154cfd7b2fe9794d5ec66e53a01f0419ee3 | |
parent | 01608844aec16fd44ae33a0715db0718966f406d (diff) | |
download | cffi-28fd3e15b9848fd7a0d1752e4728d2aad1848141.tar.gz |
Handle the case where someone has made `import weakref` return a weird proxy.alex_gaynor/handle-the-case-where-someone-has-made-i-1391634819444
Fixes: https://bugs.pypy.org/issue1688
-rw-r--r-- | cffi/model.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cffi/model.py b/cffi/model.py index d348be9..371153f 100644 --- a/cffi/model.py +++ b/cffi/model.py @@ -1,4 +1,6 @@ +import types import weakref + from .lock import allocate_lock @@ -469,8 +471,7 @@ def global_cache(srctype, ffi, funcname, *args, **kwds): # initialize the __typecache attribute, either at the module level # if ffi._backend is a module, or at the class level if ffi._backend # is some instance. - ModuleType = type(weakref) - if isinstance(ffi._backend, ModuleType): + if isinstance(ffi._backend, types.ModuleType): ffi._backend.__typecache = weakref.WeakValueDictionary() else: type(ffi._backend).__typecache = weakref.WeakValueDictionary() |