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

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

Bug Description

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

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:

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/", 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/", 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/", 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

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

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.