using deprecated message attribute of the Exception class
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Gluon |
Fix Released
|
Undecided
|
Jin Li |
Bug Description
The message attribute of the Exception class has been deprecated after the python 2.7 : https:/
Below is an example in the gluon/particleG
The do_post function:
def do_post(url, values):
resp = post(url, json=values)
if resp.status_code != 200 and resp.status_code != 201:
raise exc.GluonClient
try:
rv = json.loads(
except Exception as e:
raise exc.MalformedRe
return rv
uni test case:
@mock.
def test_do_
rsp = mock.Mock()
rsp.content = "response in wrong json format"
jsonValue = {"foo": "bar"}
Python34 test result with error:
2016-12-03 02:12:33.808892 | =======
2016-12-03 02:12:33.808914 | FAIL: gluon.tests.
2016-12-03 02:12:33.808923 | tags: worker-7
2016-12-03 02:12:33.808944 | -------
2016-12-03 02:12:33.808957 | Empty attachments:
2016-12-03 02:12:33.808965 | stderr
2016-12-03 02:12:33.808973 | stdout
2016-12-03 02:12:33.808978 |
2016-12-03 02:12:33.808991 | Traceback (most recent call last):
2016-12-03 02:12:33.809019 | File "/home/
2016-12-03 02:12:33.809032 | rv = json.loads(
2016-12-03 02:12:33.809052 | File "/usr/lib/
2016-12-03 02:12:33.809065 | return _default_
2016-12-03 02:12:33.809096 | File "/usr/lib/
2016-12-03 02:12:33.809115 | obj, end = self.raw_decode(s, idx=_w(s, 0).end())
2016-12-03 02:12:33.809135 | File "/usr/lib/
2016-12-03 02:12:33.809156 | raise ValueError(
2016-12-03 02:12:33.809173 | ValueError: Expecting value: line 1 column 1 (char 0)
2016-12-03 02:12:33.809179 |
2016-12-03 02:12:33.809199 | During handling of the above exception, another exception occurred:
2016-12-03 02:12:33.809205 |
2016-12-03 02:12:33.809217 | Traceback (most recent call last):
2016-12-03 02:12:33.809250 | File "/home/
2016-12-03 02:12:33.809264 | return func(*args, **keywargs)
2016-12-03 02:12:33.809298 | File "/home/
2016-12-03 02:12:33.809307 | jsonValue)
2016-12-03 02:12:33.809342 | File "/home/
2016-12-03 02:12:33.809357 | self.assertThat
2016-12-03 02:12:33.809392 | File "/home/
2016-12-03 02:12:33.809413 | mismatch_error = self._matchHelp
2016-12-03 02:12:33.809449 | File "/home/
2016-12-03 02:12:33.809463 | mismatch = matcher.
2016-12-03 02:12:33.809499 | File "/home/
2016-12-03 02:12:33.809516 | mismatch = self.exception_
2016-12-03 02:12:33.809553 | File "/home/
2016-12-03 02:12:33.809567 | mismatch = matcher.
2016-12-03 02:12:33.809601 | File "/home/
2016-12-03 02:12:33.809611 | reraise(*matchee)
2016-12-03 02:12:33.809646 | File "/home/
2016-12-03 02:12:33.809660 | raise exc_obj.
2016-12-03 02:12:33.809696 | File "/home/
2016-12-03 02:12:33.809706 | result = matchee()
2016-12-03 02:12:33.809741 | File "/home/
2016-12-03 02:12:33.809760 | return self._callable_
2016-12-03 02:12:33.809790 | File "/home/
2016-12-03 02:12:33.809803 | % (e.message, resp.content))
2016-12-03 02:12:33.809829 | AttributeError: 'ValueError' object has no attribute 'message'
Changed in python-gluon: | |
assignee: | nobody → Jin Li (jl7351) |
Fix proposed to branch: master /review. openstack. org/411003
Review: https:/