Python 3: Enable sm-api to work after unlock

The "min()" function works for None arguments
in Python 2 but in Python 3 raises an error.
We add a check to ensure that the function is not
called with the None argument in Python 3.

Story: 2006796
Task: 42388
Depends-On: I29a81755f732b55f67321748604b2e5d951935c9
Change-Id: I2199e0b87d342cec305edbb10483c6c038ad591c
Signed-off-by: Mihnea Saracin <Mihnea.Saracin@windriver.com>
(cherry picked from commit f2186d04c0)
This commit is contained in:
Mihnea Saracin 2021-06-15 18:13:35 +03:00 committed by Charles Short
parent ff9e32bb80
commit 0db63883c0
1 changed files with 3 additions and 1 deletions

View File

@ -35,7 +35,9 @@ JSONPATCH_EXCEPTIONS = (jsonpatch.JsonPatchException,
def validate_limit(limit):
if limit and limit < 0:
if limit is None:
return CONF.api_limit_max
elif limit < 0:
raise wsme.exc.ClientSideError(_("Limit must be positive"))
return min(CONF.api_limit_max, limit) or CONF.api_limit_max