[svn r38572] Move a bit into using high-level traceback interface instead of low-level one
--HG-- branch : trunk
This commit is contained in:
parent
c7fa5db37b
commit
cb87cd42cc
|
@ -29,10 +29,17 @@ class Outcome(object):
|
||||||
tb_info = [self.traceback_entry_repr(x, tbstyle)
|
tb_info = [self.traceback_entry_repr(x, tbstyle)
|
||||||
for x in excinfo.traceback]
|
for x in excinfo.traceback]
|
||||||
rec_index = excinfo.traceback.recursionindex()
|
rec_index = excinfo.traceback.recursionindex()
|
||||||
|
if hasattr(excinfo, 'type'):
|
||||||
etype = excinfo.type
|
etype = excinfo.type
|
||||||
if hasattr(etype, '__name__'):
|
if hasattr(etype, '__name__'):
|
||||||
etype = etype.__name__
|
etype = etype.__name__
|
||||||
return (etype, str(excinfo.value), (tb_info, rec_index))
|
else:
|
||||||
|
etype = excinfo.typename
|
||||||
|
val = getattr(excinfo, 'value', None)
|
||||||
|
if not val:
|
||||||
|
val = exinfo.exconly()
|
||||||
|
val = str(val)
|
||||||
|
return (etype, val, (tb_info, rec_index))
|
||||||
|
|
||||||
def traceback_entry_repr(self, tb_entry, tb_style):
|
def traceback_entry_repr(self, tb_entry, tb_style):
|
||||||
lineno = tb_entry.lineno
|
lineno = tb_entry.lineno
|
||||||
|
@ -46,7 +53,7 @@ class Outcome(object):
|
||||||
source = str(tb_entry.getsource()).split("\n")[relline]
|
source = str(tb_entry.getsource()).split("\n")[relline]
|
||||||
except py.error.ENOENT:
|
except py.error.ENOENT:
|
||||||
source = "[cannot get source]"
|
source = "[cannot get source]"
|
||||||
name = tb_entry.frame.code.raw.co_name
|
name = str(tb_entry.frame.code.name)
|
||||||
# XXX: Bare except. What can getsource() raise anyway?
|
# XXX: Bare except. What can getsource() raise anyway?
|
||||||
# SyntaxError, AttributeError, IndentationError for sure, check it
|
# SyntaxError, AttributeError, IndentationError for sure, check it
|
||||||
#except:
|
#except:
|
||||||
|
|
Loading…
Reference in New Issue