diff options
author | Pauli Virtanen <pav@iki.fi> | 2011-03-30 22:24:41 +0200 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2011-03-30 22:24:41 +0200 |
commit | 51a1895234b25b8bf0ace24b8ee881a91c39601c (patch) | |
tree | abbf4e0f5c57ff2896c13ec034f11e84d1be1cc4 /numpy/lib/utils.py | |
parent | 3ebc34878f3fd1200305f06ed0d6ba1a3529b457 (diff) | |
download | numpy-51a1895234b25b8bf0ace24b8ee881a91c39601c.tar.gz |
BUG: lib: catch SWIG NameError in lookfor (#1704)
Thanks to sebhaase for the patch.
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r-- | numpy/lib/utils.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 1e7364adc..924289a6a 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -924,8 +924,14 @@ def _lookfor_generate_cache(module, import_modules, regenerate): continue for n, v in _getmembers(item): - item_name = getattr(v, '__name__', "%s.%s" % (name, n)) - mod_name = getattr(v, '__module__', None) + try: + item_name = getattr(v, '__name__', "%s.%s" % (name, n)) + mod_name = getattr(v, '__module__', None) + except NameError: + # ref. SWIG's global cvars + # NameError: Unknown C global variable + item_name = "%s.%s" % (name, n) + mod_name = None if '.' not in item_name and mod_name: item_name = "%s.%s" % (mod_name, item_name) @@ -946,7 +952,10 @@ def _lookfor_generate_cache(module, import_modules, regenerate): elif hasattr(item, "__call__"): kind = "func" - doc = inspect.getdoc(item) + try: + doc = inspect.getdoc(item) + except NameError: # ref SWIG's NameError: Unknown C global variable + doc = None if doc is not None: cache[name] = (doc, kind, index) |