[Piglit] [PATCH] framework: use proper exception message passing
Dylan Baker
baker.dylan.c at gmail.com
Mon Jun 8 11:12:48 PDT 2015
The correct way to handle error messages from exceptions is to use str()
or unicode() on them, not using e.message.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
This is a trivial patch, I'll push this shortly unless there are
objections.
framework/backends/__init__.py | 2 +-
framework/backends/json.py | 2 +-
framework/exceptions.py | 6 +++---
framework/test/base.py | 4 ++--
framework/test/glsl_parser_test.py | 2 +-
framework/tests/utils.py | 2 +-
tests/igt.py | 2 +-
7 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/framework/backends/__init__.py b/framework/backends/__init__.py
index e2f199a..43a45d1 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 2fe239c..48a34a8 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 1d8cd34..655a5db 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 cd15a9d..f29fc94 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 76576ae..e5cd542 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 a970984..0021681 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
diff --git a/tests/igt.py b/tests/igt.py
index 076b179..01531d2 100644
--- a/tests/igt.py
+++ b/tests/igt.py
@@ -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
--
2.4.2
More information about the Piglit
mailing list