diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2015-06-08 11:09:46 -0700 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2015-06-09 15:11:54 -0700 |
commit | 1ada8b0db9b6a0ac877b7ae4776a19e5b76c6940 (patch) | |
tree | 232161d98ba798df620d4a4030e90d2b04c54ae8 /framework | |
parent | 5121b26ba39dc3747fd7a9a680b51edb627f801c (diff) |
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: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/backends/__init__.py | 2 | ||||
-rw-r--r-- | framework/backends/json.py | 2 | ||||
-rw-r--r-- | framework/exceptions.py | 6 | ||||
-rw-r--r-- | framework/test/base.py | 4 | ||||
-rw-r--r-- | framework/test/glsl_parser_test.py | 2 | ||||
-rw-r--r-- | framework/tests/utils.py | 2 |
6 files changed, 9 insertions, 9 deletions
diff --git a/framework/backends/__init__.py b/framework/backends/__init__.py index e2f199a92..43a45d1c1 100644 --- a/framework/backends/__init__.py +++ b/framework/backends/__init__.py @@ -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: diff --git a/framework/backends/json.py b/framework/backends/json.py index 2fe239c3f..48a34a871 100644 --- a/framework/backends/json.py +++ b/framework/backends/json.py @@ -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 diff --git a/framework/exceptions.py b/framework/exceptions.py index 1d8cd344e..655a5dbcf 100644 --- a/framework/exceptions.py +++ b/framework/exceptions.py @@ -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 diff --git a/framework/test/base.py b/framework/test/base.py index cd15a9d6f..f29fc949a 100644 --- a/framework/test/base.py +++ b/framework/test/base.py @@ -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 diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py index 76576ae3c..e5cd54288 100644 --- a/framework/test/glsl_parser_test.py +++ b/framework/test/glsl_parser_test.py @@ -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) diff --git a/framework/tests/utils.py b/framework/tests/utils.py index a970984b1..00216812f 100644 --- a/framework/tests/utils.py +++ b/framework/tests/utils.py @@ -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 |