[pypy-commit] pypy default: Try never to crash when inspect.getsource() fails.

arigo noreply at buildbot.pypy.org
Wed Nov 2 15:58:00 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r48659:0dedcb956aa5
Date: 2011-11-02 15:57 +0100
http://bitbucket.org/pypy/pypy/changeset/0dedcb956aa5/

Log:	Try never to crash when inspect.getsource() fails.

diff --git a/pypy/tool/sourcetools.py b/pypy/tool/sourcetools.py
--- a/pypy/tool/sourcetools.py
+++ b/pypy/tool/sourcetools.py
@@ -107,10 +107,8 @@
     else:
         try:
             src = inspect.getsource(object)
-        except IOError:
-            return None
-        except IndentationError:
-            return None
+        except Exception:   # catch IOError, IndentationError, and also rarely
+            return None     # some other exceptions like IndexError
     if hasattr(name, "__sourceargs__"):
         return src % name.__sourceargs__
     return src


More information about the pypy-commit mailing list