type() method should be replaced with isinstance() in nova/utils.py

Bug #1267300 reported by lizheming
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
lizheming

Bug Description

In nova/utils.py, a func use the "type" method to determine the type. It's bertter to use the "isinstance" method instead.
The code is:
def convert_version_to_int(version):
    try:
        if type(version) == str:
            version = convert_version_to_tuple(version)
       if type(version) == tuple:
           return reduce(lambda x, y: (x * 1000) + y, version)
    except Exception:
           raise exception.NovaException(message="Hypervisor version invalid.")

this bug is fixed in glance:
https://review.openstack.org/#/c/65611/4

lizheming (lizheming-li)
Changed in nova:
assignee: nobody → lizheming (lizheming-li)
lizheming (lizheming-li)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

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

Reviewed: https://review.openstack.org/65856
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=9f7c5bf5ad38237f2adac980afb69fcdb26678a3
Submitter: Jenkins
Branch: master

commit 9f7c5bf5ad38237f2adac980afb69fcdb26678a3
Author: lizheming <email address hidden>
Date: Fri Jan 10 11:43:37 2014 +0800

    replace type() to isinstance() in nova

    In nova/utils.py, a func use the "type" method to
    determine the type. It's bertter to use the "isinstance"
    method instead.this bug is fixed in glance:
    https://review.openstack.org/#/c/65611/4

    Change-Id: I10d25d2308436239c50cf3932c212e22c45f92a8
    Closes-Bug: #1267300

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