Exception raise error

Bug #916827 reported by Zhongyue Luo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Undecided
Zhongyue Luo

Bug Description

ERROR: test_exception_raising (keystone.test.unit.test_buffout.TestOutputBufferContents)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/openstack/git/keystone/keystone/test/unit/test_buffout.py", line 91, in test_exception_raising
    self.assertRaises(ValueError, raise_value_error)
  File "/home/openstack/git/keystone/.venv/lib/python2.6/site-packages/unittest2/case.py", line 475, in assertRaises
    callableObj(*args, **kwargs)
  File "/home/openstack/git/keystone/keystone/test/unit/test_buffout.py", line 89, in raise_value_error
    raise ValueError()
  File "/home/openstack/git/keystone/keystone/tools/buffout.py", line 27, in __exit__
    raise
TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType

----------------------------------------------------------------------

"raise" should be "raise exc_type, exc_value, traceback"

Zhongyue Luo (zyluo)
Changed in keystone:
assignee: nobody → LZY (lzyeval)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

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

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

Reviewed: https://review.openstack.org/3057
Committed: http://github.com/openstack/keystone/commit/45c62a8e86bbd35a50fefe33248b01f6482982a8
Submitter: Jenkins
Branch: master

commit 45c62a8e86bbd35a50fefe33248b01f6482982a8
Author: Zhongyue Luo <email address hidden>
Date: Sun Jan 15 11:31:23 2012 -0500

    Exception raise error

    Fixes bug #916827

    The reason for ignoring W602 is explained at
    https://github.com/openstack/nova/blob/master/run_tests.sh#L101

    Change-Id: I2e12e3ababcfd0de15903c47eef27f5e514ee427

Changed in keystone:
status: In Progress → Fix Committed
Revision history for this message
Ionuț Arțăriși (mapleoin) wrote :

Shouldn't this method return false instead of re-raising the error? As per: http://docs.python.org/library/stdtypes.html?highlight=__exit__#contextmanager.__exit__

The exception passed in should never be reraised explicitly - instead, this method should return a false value to indicate that the method completed successfully and does not want to suppress the raised exception. This allows context management code (such as contextlib.nested) to easily detect whether or not an __exit__() method has actually failed.

Changed in keystone:
status: Fix Committed → Opinion
Revision history for this message
Zhongyue Luo (zyluo) wrote :

Ionuț: It does look so. Could you report a bugfix yourself and submit a patch? Otherwise, I'll send resend a patch at 9:00 UTC+8.

Revision history for this message
Zhongyue Luo (zyluo) wrote :

I can't send the patch because I'm getting a unittest error somewhere else.

./run_tests.sh unit.test_migrations

Am I the only one?

Revision history for this message
Dolph Mathews (dolph) wrote : Re: [Bug 916827] Re: Exception raise error

What's the unittest error you're seeing?

Revision history for this message
Zhongyue Luo (zyluo) wrote :

I was because I forgot to change the default python version to 2.7 on the box I'm running keystone. Everythings ok now.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

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

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

Reviewed: https://review.openstack.org/3187
Committed: http://github.com/openstack/keystone/commit/7681a01171b7ebdf8c0d578de5eb129af50b8600
Submitter: Jenkins
Branch: master

commit 7681a01171b7ebdf8c0d578de5eb129af50b8600
Author: Zhongyue Luo <email address hidden>
Date: Thu Jan 19 13:39:42 2012 -0500

    Exception raise error

    Fixes bug #916827

    As per: http://docs.python.org/library/stdtypes.html
    ?highlight=__exit__#contextmanager.__exit__

    Ionut Artarisi wrote:

    The exception passed in should never be reraised explicitly - instead,
    this method should return a false value to indicate that the method completed
    successfully and does not want to suppress the raised exception.
    This allows context management code (such as contextlib.nested) to easily
    detect whether or not an __exit__() method has actually failed.

    Change-Id: I79bbac32b5c99742b5cb283c6e55e6204bf92adc

Changed in keystone:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in keystone:
status: Fix Committed → Fix Released
milestone: none → essex-3
Thierry Carrez (ttx)
Changed in keystone:
milestone: essex-3 → 2012.1
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.