Permalink
Browse files

util/agentwrapper: add workaround for python3.7 BaseException repr ch…

…ange

Until now, repr(BaseException('spam')) was "BaseException('spam',)".
This was changed with https://bugs.python.org/issue30399. To hide that
change, we just remove the trailing ',' if it's there.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
  • Loading branch information...
jluebbe committed Jan 4, 2019
1 parent c711c90 commit 87850ba6d16cc1d0d55dbce60b433443b20eddd7
Showing with 7 additions and 2 deletions.
  1. +6 −1 labgrid/util/agentwrapper.py
  2. +1 −1 tests/test_agent.py
@@ -65,7 +65,12 @@ def call(self, method, *args, **kwargs):
elif 'exception' in response:
self.agent.wait()
self.agent = None
raise AgentException(response['exception'])
e = response['exception']
# work around BaseException repr change
# https://bugs.python.org/issue30399
if e[-2:] == ',)':
e = e[:-2] + ')'
raise AgentException(e)
else:
self.agent.wait()
self.agent = None
@@ -59,7 +59,7 @@ def test_exception(subprocess_mock):
aw = AgentWrapper('localhost')
with pytest.raises(AgentException) as excinfo:
aw.error('foo')
assert excinfo.value.args == ("RuntimeError('foo',)",)
assert excinfo.value.args == ("RuntimeError('foo')",)

def test_error(subprocess_mock):
aw = AgentWrapper('localhost')

0 comments on commit 87850ba

Please sign in to comment.