cinderclient.exceptions.ClientException fails on py34 if message is not provided

Bug #1481478 reported by Matt Riedemann
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-cinderclient
Fix Released
Medium
Matt Riedemann

Bug Description

This fails on python 3.4 if the message kwarg evaluates to False:

http://git.openstack.org/cgit/openstack/python-cinderclient/tree/cinderclient/exceptions.py?id=1.1.2#n85

because self.__class__.message doesn't exist for exceptions in python 3.4.

You can see the failure here in a unit test that hit this:

http://logs.openstack.org/50/209150/2/check/gate-python-cinderclient-python34/18f034e/console.html#_2015-08-04_19_38_16_567

2015-08-04 19:38:16.567 | FAIL: cinderclient.tests.unit.test_exceptions.ExceptionsTest.test_from_response_no_body_message
2015-08-04 19:38:16.567 | tags: worker-3
2015-08-04 19:38:16.567 | ----------------------------------------------------------------------
2015-08-04 19:38:16.567 | Empty attachments:
2015-08-04 19:38:16.567 | stderr
2015-08-04 19:38:16.567 | stdout
2015-08-04 19:38:16.568 |
2015-08-04 19:38:16.568 | Traceback (most recent call last):
2015-08-04 19:38:16.568 | File "/home/jenkins/workspace/gate-python-cinderclient-python34/cinderclient/tests/unit/test_exceptions.py", line 31, in test_from_response_no_body_message
2015-08-04 19:38:16.568 | ex = exceptions.from_response(response, body)
2015-08-04 19:38:16.568 | File "/home/jenkins/workspace/gate-python-cinderclient-python34/cinderclient/exceptions.py", line 207, in from_response
2015-08-04 19:38:16.568 | request_id=request_id)
2015-08-04 19:38:16.568 | File "/home/jenkins/workspace/gate-python-cinderclient-python34/cinderclient/exceptions.py", line 91, in __init__
2015-08-04 19:38:16.568 | self.message = message or self.__class__.message
2015-08-04 19:38:16.568 | AttributeError: type object 'ClientException' has no attribute 'message'

Tags: py34
Matt Riedemann (mriedem)
Changed in python-cinderclient:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Matt Riedemann (mriedem)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-cinderclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/209258

Changed in python-cinderclient:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-cinderclient (master)

Reviewed: https://review.openstack.org/209258
Committed: https://git.openstack.org/cgit/openstack/python-cinderclient/commit/?id=03542ee65a5e818a5d908a85a6a9eba21ef63b53
Submitter: Jenkins
Branch: master

commit 03542ee65a5e818a5d908a85a6a9eba21ef63b53
Author: Matt Riedemann <email address hidden>
Date: Tue Aug 4 14:20:53 2015 -0700

    Fix ClientException init when there is no message on py34

    BaseException.message was removed in python 3 per PEP 0352 so if no
    message is passed to the ClientException __init__ it will blow up:

    AttributeError: type object 'ClientException' has no attribute 'message'

    So this change does two things:

    1. Default to 'n/a' for message and details when body['keys'] doesn't
       have a message or details in it (which should be fine since
       from_response defaults to n/a if 'keys' is not in body).
    2. Use getattr for self.__class__.message and default to None if that
       attribute is not set. Arguably we could just remove this and make
       the message kwarg default to 'n/a' in ClientException.__init__ but
       I figured that was more invasive.

    Closes-Bug: #1481478

    Change-Id: I738cb9c8d4f015048c45a1df16bf18e29190e392

Changed in python-cinderclient:
status: In Progress → Fix Committed
Changed in python-cinderclient:
milestone: none → 1.4.0
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-cinderclient 1.4.0

This issue was fixed in the openstack/python-cinderclient 1.4.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.