Commit 1ada8b0d authored by Dylan Baker's avatar Dylan Baker

framework: use proper exception message passing

The correct way to get error messages from exceptions is to use str()
or unicode() on them, not by reading the message attribute. This is even
more relevant as we look toward python 3, where exceptions don't have a
message attribute at all.
Signed-off-by: default avatarDylan Baker <dylanx.c.baker@intel.com>
parent 5121b26b
......@@ -167,7 +167,7 @@ def set_meta(backend, result):
# callable then we'll get a TypeError, and we're looking for NoneType
# in the message. If we get that we really want a
# BackendNotImplementedError
if e.message == "'NoneType' object is not callable":
if str(e) == "'NoneType' object is not callable":
raise BackendNotImplementedError(
'meta function for {} not implemented.'.format(backend))
else:
......
......@@ -219,7 +219,7 @@ def _load(results_file):
raise exceptions.PiglitFatalError(
'While loading json results file: "{}",\n'
'the following error occured:\n{}'.format(results_file.name,
e.message))
str(e)))
return result
......
......@@ -49,12 +49,12 @@ def handler(func):
try:
func(*args, **kwargs)
except PiglitFatalError as e:
print('Fatal Error: {}'.format(e.message), file=sys.stderr)
print('Fatal Error: {}'.format(str(e)), file=sys.stderr)
sys.exit(1)
except (PiglitInternalError, PiglitException) as e:
print('Warning: An internal exception that should have '
'been handled was not. This is bug and should be reported.\n'
'BUG: {}'.format(e.message),
'BUG: {}'.format(str(e)),
file=sys.stderr)
if _DEBUG:
raise e
......@@ -62,7 +62,7 @@ def handler(func):
except Exception as e: # pylint: disable=broad-except
print('Warning: A python exception that should have '
'been handled was not. This is bug and should be reported.\n'
'BUG: {}'.format(e.message),
'BUG: {}'.format(str(e)),
file=sys.stderr)
if _DEBUG:
raise e
......
......@@ -212,7 +212,7 @@ class Test(object):
self.is_skip()
except TestIsSkip as e:
self.result['result'] = 'skip'
self.result['out'] = unicode(e.message)
self.result['out'] = unicode(e)
self.result['err'] = u""
self.result['returncode'] = None
return
......@@ -221,7 +221,7 @@ class Test(object):
self._run_command()
except TestRunError as e:
self.result['result'] = unicode(e.status)
self.result['out'] = unicode(e.message)
self.result['out'] = unicode(e)
self.result['err'] = u""
self.result['returncode'] = None
return
......
......@@ -72,7 +72,7 @@ class GLSLParserTest(PiglitBaseTest):
filepath)
except GLSLParserInternalError as e:
raise exceptions.PiglitFatalError(
'In file "{}":\n{}'.format(filepath, e.message))
'In file "{}":\n{}'.format(filepath, str(e)))
super(GLSLParserTest, self).__init__(command, run_concurrent=True)
......
......@@ -331,7 +331,7 @@ def not_raises(exceptions):
try:
func(*args, **kwargs)
except exceptions as e:
raise TestFailure(e.message)
raise TestFailure(str(e))
return _inner
......
......@@ -93,7 +93,7 @@ class IGTTestProfile(TestProfile):
try:
check_environment()
except exceptions.PiglitInternalError as e:
raise exceptions.PiglitFatalError(e.message)
raise exceptions.PiglitFatalError(str(e))
profile = IGTTestProfile() # pylint: disable=invalid-name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment