mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-30 09:02:58 +08:00
BUG: Fix Python 3 support for Cythonized Security object
Python 3 for some reason doesn't like usage of the cmp() built-in, so instead of using cmp(), just subtract the two ints being compared. In addition to making this work with Python 3, it should also be more performant since it no longer requires calling the cmp() method.
This commit is contained in:
@@ -99,7 +99,7 @@ cdef class Security:
|
||||
retvals = [True, True, False, True, False, False]
|
||||
return retvals[op]
|
||||
|
||||
compared = cmp(self.sid, other_as_int)
|
||||
compared = self.sid - other_as_int
|
||||
|
||||
# Handle == and != first because they're significantly more common
|
||||
# operations.
|
||||
@@ -111,16 +111,16 @@ cdef class Security:
|
||||
return compared != 0
|
||||
elif op == 0:
|
||||
# <
|
||||
return compared == -1
|
||||
return compared < 0
|
||||
elif op == 1:
|
||||
# <=
|
||||
return compared == -1 or compared == 0
|
||||
return compared <= 0
|
||||
elif op == 4:
|
||||
# >
|
||||
return compared == 1
|
||||
return compared > 0
|
||||
elif op == 5:
|
||||
# >=
|
||||
return compared == 1 or compared == 0
|
||||
return compared >= 0
|
||||
|
||||
def __str__(self):
|
||||
if self.symbol:
|
||||
|
||||
Reference in New Issue
Block a user