Replace list.sort() with sorted()#52
Conversation
In OpenStack heatclient project, there is error running in py33 env: https://bugs.launchpad.net/python-heatclient/+bug/1243096 For the Python 2&3 compatability, use sorted() builtin to replace list.sort(). This change is verified in OpenStack heatclient/novaclient projects. (tox -e py27 / tox -e py33)
|
I don't think the problem is Python 3.3 compatibility. The docs are pretty clear that Instead of replacing with |
|
I think you've misinterpreted the problem -
Thats the issue, and sorted has the problem too:
so the thing letting your tests pass is the use of key, which can be used in list.sort() as well.
However, list.sort is very efficient, so please don't change to sorted. |
|
In fact, a further thought occurs to me. The fact the objects are being compared at all indicates you have identical sort keys in that list. As the sort keys are the test ids, this indicates you have a bad test id in your test suite, and even if it runs you'll get bad data out. So this change isn't needed - but please open a bug that we don't give a good error message about your corrupt test suite. |
|
Agree with you, new bug is raised for this: I will make some further investigation to find the root cause of failed test id. |
In OpenStack heatclient project, there is error running in py33 env:
https://bugs.launchpad.net/python-heatclient/+bug/1243096
For the Python 2&3 compatability, use sorted() builtin to replace
list.sort().
This change is verified in OpenStack heatclient/novaclient projects.
(tox -e py27 / tox -e py33)