aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-03-17 16:56:39 +0000
committerEwan Mellor <ewan@xensource.com>2007-03-17 16:56:39 +0000
commit716d0617c936b721deb6fc2212add0acca58af32 (patch)
tree8b9f31e1e4215b2351ffb62a57c18d8f122e9f27 /tools
parentc95d97855e1470874178e25f645a45ca7d9da1dc (diff)
downloadxen-716d0617c936b721deb6fc2212add0acca58af32.tar.gz
xen-716d0617c936b721deb6fc2212add0acca58af32.tar.bz2
xen-716d0617c936b721deb6fc2212add0acca58af32.zip
Work around bug in Python's inspect module -- catch an IndexError exception
if the source-code lookup fails. Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/python/xen/xend/XendLogging.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/python/xen/xend/XendLogging.py b/tools/python/xen/xend/XendLogging.py
index 6d6140188d..3d6b678f1d 100644
--- a/tools/python/xen/xend/XendLogging.py
+++ b/tools/python/xen/xend/XendLogging.py
@@ -59,6 +59,18 @@ if 'TRACE' not in logging.__dict__:
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")