Switching expression order within if condition
In nova/cmd/manage.py, on line 294 [1] there is the following line: if value['limit'] < 0 or value['limit'] is None: The problem occurs when value['limit'] is None, as this line tries to compare None (object) with an integer value. This comparsion is totally okay (without errors) in Python27. But, if you run this on Python34, a TypError is raised: TypeError: unorderable types: NoneType() < int() It is simply fixed with swapping the two expressions within the if condition. Now if value['limit'] is None, the first expression becomes true and second one does not get evaluated. TrivialFix [1]: https://github.com/openstack/nova/blob/master/nova/cmd/manage.py#L294 Change-Id: Id2b1ed67e1c2c9f1d1aa5a23740db2b18e2e7141
This commit is contained in:
parent
0d83e08da4
commit
6bd802912d
@ -291,7 +291,7 @@ class ProjectCommands(object):
|
||||
else:
|
||||
quota = QUOTAS.get_project_quotas(ctxt, project_id)
|
||||
for key, value in six.iteritems(quota):
|
||||
if value['limit'] < 0 or value['limit'] is None:
|
||||
if value['limit'] is None or value['limit'] < 0:
|
||||
value['limit'] = 'unlimited'
|
||||
print(print_format % (key, value['limit'], value['in_use'],
|
||||
value['reserved']))
|
||||
|
Loading…
Reference in New Issue
Block a user