From a333528469c886095aa10d6c2fe92558c1bd3b79 Mon Sep 17 00:00:00 2001 From: "ChangBo Guo(gcb)" Date: Tue, 23 Dec 2014 12:12:24 +0800 Subject: [PATCH] Drop workarounds for python2.6 We drop python 2.6 support in Kilo, so we can remove workarounds for python2.6 now. Change-Id: I18b6a1adf398a5fc8f75d0f6276f6896846dbf3a --- nova/api/openstack/wsgi.py | 6 +----- nova/virt/hyperv/vhdutilsv2.py | 10 +++------- nova/virt/vmwareapi/vm_util.py | 4 +--- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index ca02756afc..9aa460bbca 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -719,11 +719,7 @@ class ResourceExceptionHandler(object): raise Fault(exception.ConvertedException( code=ex_value.code, explanation=ex_value.format_message())) - - # Under python 2.6, TypeError's exception value is actually a string, - # so test # here via ex_type instead: - # http://bugs.python.org/issue7853 - elif issubclass(ex_type, TypeError): + elif isinstance(ex_value, TypeError): exc_info = (ex_type, ex_value, ex_traceback) LOG.error(_LE('Exception handling resource: %s'), ex_value, exc_info=exc_info) diff --git a/nova/virt/hyperv/vhdutilsv2.py b/nova/virt/hyperv/vhdutilsv2.py index 438812f92f..6f6a027a00 100644 --- a/nova/virt/hyperv/vhdutilsv2.py +++ b/nova/virt/hyperv/vhdutilsv2.py @@ -99,14 +99,10 @@ class VHDUtilsV2(vhdutils.VHDUtils): image_man_svc = self._conn.Msvm_ImageManagementService()[0] vhd_info_xml = self._get_vhd_info_xml(image_man_svc, child_vhd_path) - # Can't use ".//PROPERTY[@NAME='ParentPath']/VALUE" due to - # compatibility requirements with Python 2.6 et = ElementTree.fromstring(vhd_info_xml) - for item in et.findall("PROPERTY"): - name = item.attrib["NAME"] - if name == 'ParentPath': - item.find("VALUE").text = parent_vhd_path - break + item = et.find(".//PROPERTY[@NAME='ParentPath']/VALUE") + if item: + item.text = parent_vhd_path vhd_info_xml = ElementTree.tostring(et) (job_path, ret_val) = image_man_svc.SetVirtualHardDiskSettingData( diff --git a/nova/virt/vmwareapi/vm_util.py b/nova/virt/vmwareapi/vm_util.py index 8c6bab1691..2152de8f9d 100644 --- a/nova/virt/vmwareapi/vm_util.py +++ b/nova/virt/vmwareapi/vm_util.py @@ -1040,9 +1040,7 @@ def propset_dict(propset): if propset is None: return {} - # TODO(hartsocks): once support for Python 2.6 is dropped - # change to {[(prop.name, prop.val) for prop in propset]} - return dict([(prop.name, prop.val) for prop in propset]) + return {prop.name: prop.val for prop in propset} def get_vmdk_backed_disk_uuid(hardware_devices, volume_uuid):