direct-io.hg

changeset 14422:f40bd358129a

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>
author Ewan Mellor <ewan@xensource.com>
date Sat Mar 17 16:56:39 2007 +0000 (2007-03-17)
parents 98eacf1b075c
children 2adbc1d22fe7
files tools/python/xen/xend/XendLogging.py
line diff
     1.1 --- a/tools/python/xen/xend/XendLogging.py	Sat Mar 17 12:24:32 2007 +0000
     1.2 +++ b/tools/python/xen/xend/XendLogging.py	Sat Mar 17 16:56:39 2007 +0000
     1.3 @@ -59,6 +59,18 @@ if 'TRACE' not in logging.__dict__:
     1.4                      return filename, frame[2]
     1.5      logging.Logger.findCaller = findCaller
     1.6  
     1.7 +    # Work around a bug in Python's inspect module: findsource is supposed to
     1.8 +    # raise IOError if it fails, with other functions in that module coping
     1.9 +    # with that, but some people are seeing IndexError raised from there.
    1.10 +    if hasattr(inspect, 'findsource'):
    1.11 +        real_findsource = getattr(inspect, 'findsource')
    1.12 +        def findsource(*args, **kwargs):
    1.13 +            try:
    1.14 +                return real_findsource(*args, **kwargs)
    1.15 +            except IndexError, exn:
    1.16 +                raise IOError(exn)
    1.17 +        inspect.findsource = findsource
    1.18 +
    1.19  
    1.20  log = logging.getLogger("xend")
    1.21