py33: 'dict_keys' object does not support indexing

Bug #1229005 reported by Kui Shi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
Undecided
Kui Shi

Bug Description

======================================================================
 FAIL: novaclient.tests.v1_1.test_servers.ServersTest.test_confirm_resized_server
 tags: worker-1

----------------------------------------------------------------------
 Empty attachments:
   stderr
   stdout

 Traceback (most recent call last):
   File "/home/jenkins/workspace/gate-python-novaclient-python33/novaclient/tests/v1_1/test_servers.py", line 267, in test_confirm_resized_server
     s.confirm_resize()
   File "/home/jenkins/workspace/gate-python-novaclient-python33/novaclient/v1_1/servers.py", line 269, in confirm_resize
     self.manager.confirm_resize(self)
   File "/home/jenkins/workspace/gate-python-novaclient-python33/novaclient/v1_1/servers.py", line 754, in confirm_resize
     self._action('confirmResize', server)
   File "/home/jenkins/workspace/gate-python-novaclient-python33/novaclient/v1_1/servers.py", line 951, in _action
     return self.api.client.post(url, body=body)
   File "/home/jenkins/workspace/gate-python-novaclient-python33/novaclient/client.py", line 232, in post
     return self._cs_request(url, 'POST', **kwargs)
   File "/home/jenkins/workspace/gate-python-novaclient-python33/novaclient/tests/v1_1/fakes.py", line 84, in _cs_request
     status, headers, body = getattr(self, callback)(**kwargs)
   File "/home/jenkins/workspace/gate-python-novaclient-python33/novaclient/tests/v1_1/fakes.py", line 491, in post_servers_1234_action
     action = body.keys()[0]
 TypeError: 'dict_keys' object does not support indexing

Revision history for this message
Kui Shi (skuicloud) wrote :

use a python 2&3 compatible method to get the "first" value of dict:

a={'aaa':111, 'bbb':222}

print (a[list(a)[0]])

Changed in python-novaclient:
assignee: nobody → Kui Shi (skuicloud)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

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

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

Reviewed: https://review.openstack.org/47779
Committed: http://github.com/openstack/python-novaclient/commit/f1c3b79c2bb1805098cf55d0aaa23faf664b48ea
Submitter: Jenkins
Branch: master

commit f1c3b79c2bb1805098cf55d0aaa23faf664b48ea
Author: Kui Shi <email address hidden>
Date: Sun Sep 22 22:06:41 2013 +0800

    py33: 'dict_keys' object does not support indexing

    In python 3, dict.keys() is a class of 'dict_keys', it does not
    support indexing.

    Cast the dict to list to get the "first" value of dict, which is
    compatible with python 2&3.

    Closes-Bug: #1229005

    Change-Id: I561b7ada9e5ad936659a657b3161a9b93a15a788

Changed in python-novaclient:
status: In Progress → Fix Committed
Revision history for this message
melanie witt (melwitt) wrote :

novaclient 2.16.0 released on 2/26/2014

Changed in python-novaclient:
status: Fix Committed → Fix Released
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.