Mercurial > p > roundup > code
changeset 8294:302c797756e6
fix: issue2550962. remove assert in Role::hasPermission
issue2550962 - Check uses of assert in roundup code.
An assert was used to make sure that a classname always accompoanied
an itemid in hasPermission. The Security::hasPErmission has an if
clause that does the same check and raises a ValueError.
Remove asserts because they ae removed when running python in
optimized mode.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 19 Jan 2025 19:29:17 -0500 |
| parents | 5d1f833801f9 |
| children | bbc99def147a |
| files | roundup/security.py |
| diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/security.py Sun Jan 19 11:42:40 2025 -0500 +++ b/roundup/security.py Sun Jan 19 19:29:17 2025 -0500 @@ -267,7 +267,9 @@ def hasPermission (self, db, perm, uid, classname, property, itemid, chk): # if itemid is given a classname must, too, checked in caller - assert not itemid or classname + if itemid and classname is None: + raise ValueError('classname must accompany itemid') + perms = self._permissions if perm not in perms: return False
