From 630728657a7d76c623d9929a309d594c9d823e6e Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 28 Feb 2017 08:45:05 -0800 Subject: Replace calling traceback to get format of traceback output to just a formatted string as the frmat is stable and we're not supporting older versions of python whose formats varied. The traceback approach broke with py3 and is honestly overcomplicated --- QMTest/TestSCons.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 8049930..e7175fb 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -563,21 +563,26 @@ class TestSCons(TestCommon): Returns a Python error line for output comparisons. The exec of the traceback line gives us the correct format for - this version of Python. Before 2.5, this yielded: - - File "", line 1, ? - - Python 2.5 changed this to: + this version of Python. File "", line 1, We stick the requested file name and line number in the right places, abstracting out the version difference. """ - exec('import traceback; x = traceback.format_stack()[-1]') - x = x.lstrip() - x = x.replace('', file) - x = x.replace('line 1,', 'line %s,' % line) + # This routine used to use traceback to get the proper format + # that doesn't work well with py3. And the format of the + # traceback seems to be stable, so let's just format + # an appropriate string + # + #exec('import traceback; x = traceback.format_stack()[-1]') + # import traceback + # x = traceback.format_stack() + # x = # XXX: .lstrip() + # x = x.replace('', file) + # x = x.replace('line 1,', 'line %s,' % line) + # x="\n".join(x) + x='File "%s", line %s, in \n'%(file,line) return x def normalize_ps(self, s): -- cgit v0.12