InvalidContentType can't be raised because of error in constructor

Bug #1104090 reported by Tatyanka
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Tatyanka

Bug Description

InvalidContentType exception class is defined two times: in quantum.openstack.common.exception and quantum.common.exceptions with two different signatures.

A lot of code like (https://github.com/openstack/quantum/blob/master/quantum/wsgi.py#L394) imports one of them but attempts to use it with the signature of another one, which ends with an error like:

Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 327, in run
    testMethod()
  File "./repos/quantum/quantum/tests/unit/test_wsgi.py", line 225, in test_serialize_content_type_unknow
    self.assertRaises(exceptions.InvalidContentType, serializer.serialize, input_data, content_type)
  File "/usr/lib/python2.7/unittest/case.py", line 471, in assertRaises
    callableObj(*args, **kwargs)
  File "./repos/quantum/quantum/wsgi.py", line 965, in serialize
    return self._get_serialize_handler(content_type)(data)
  File "./repos/quantum/quantum/wsgi.py", line 961, in _get_serialize_handler
    raise exception.InvalidContentType(content_type=content_type)
TypeError: __init__() got an unexpected keyword argument 'content_type'

Changed in quantum:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to quantum (master)

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

Changed in quantum:
assignee: nobody → Tatyana (tatyana-leontovich)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to quantum (master)

Reviewed: https://review.openstack.org/20400
Committed: http://github.com/openstack/quantum/commit/cb7dae08aee84d49537477d25a5798f515ff2321
Submitter: Jenkins
Branch: master

commit cb7dae08aee84d49537477d25a5798f515ff2321
Author: Tatyana Leontovich <email address hidden>
Date: Thu Jan 24 17:33:57 2013 +0200

    Fix InvalidContentType can't be raised because of error in constructor

    InvalidContentType exception class is defined two times:
    in quantum.openstack.common.exception and quantum.common.exceptions
    with two different signatures.
    A lot of code like wsgi.Serializer.serialize() imports one of them but
    attempts to use it with the signature of another one, which ends with
    TypeError exception.

    This change fixes the bug by removing the second definition of
    InvalidContentType class and leaving only one which works correctly
    with all code. Also adds unit tests for exceptions to prevent this and similar bugs.

    Change-Id: I5d932d75ad184a0a6c6419190f2940bd47b7504e
    Fixes: bug #1104090

Changed in quantum:
status: In Progress → Fix Committed
Akihiro Motoki (amotoki)
Changed in quantum:
milestone: none → grizzly-3
Thierry Carrez (ttx)
Changed in quantum:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in quantum:
milestone: grizzly-3 → 2013.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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