Avoid compare None type using min()

In python3, min() compare None will raise an exception, this breaks the
api call.

Partially-Implements: blueprint magnum-python3

Change-Id: Idb83d6b6e21aab4e41a36824aab69e177fa7b5e0
This commit is contained in:
Yang Hongyang 2016-02-27 15:00:34 +08:00
parent cb1fde6e77
commit 5650b7b954
1 changed files with 4 additions and 1 deletions

View File

@ -35,7 +35,10 @@ def validate_limit(limit):
if limit is not None and limit <= 0:
raise wsme.exc.ClientSideError(_("Limit must be positive"))
return min(CONF.api.max_limit, limit) or CONF.api.max_limit
if limit is not None:
return min(CONF.api.max_limit, limit)
else:
return CONF.api.max_limit
def validate_sort_dir(sort_dir):