[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Work around bug in Python's inspect module -- catch an IndexError exception



# HG changeset patch
# User Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1174150599 0
# Node ID f40bd358129a8f83e4503bc7129c1e6598563c8c
# Parent  98eacf1b075cc8bb2ed9136a0ca381840b8d7ae2
Work around bug in Python's inspect module -- catch an IndexError exception
if the source-code lookup fails.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendLogging.py |   12 ++++++++++++
 1 files changed, 12 insertions(+)

diff -r 98eacf1b075c -r f40bd358129a tools/python/xen/xend/XendLogging.py
--- a/tools/python/xen/xend/XendLogging.py      Sat Mar 17 12:24:32 2007 +0000
+++ b/tools/python/xen/xend/XendLogging.py      Sat Mar 17 16:56:39 2007 +0000
@@ -58,6 +58,18 @@ if 'TRACE' not in logging.__dict__:
                 else:
                     return filename, frame[2]
     logging.Logger.findCaller = findCaller
+
+    # Work around a bug in Python's inspect module: findsource is supposed to
+    # raise IOError if it fails, with other functions in that module coping
+    # with that, but some people are seeing IndexError raised from there.
+    if hasattr(inspect, 'findsource'):
+        real_findsource = getattr(inspect, 'findsource')
+        def findsource(*args, **kwargs):
+            try:
+                return real_findsource(*args, **kwargs)
+            except IndexError, exn:
+                raise IOError(exn)
+        inspect.findsource = findsource
 
 
 log = logging.getLogger("xend")

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.