Skip to content

Commit

Permalink
More Python 3 simplifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed Jan 19, 2023
1 parent 49e5aec commit 04bf2b4
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/zope/sequencesort/ssort.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@
from locale import strcoll


try:
cmp = cmp # always put in our namespace; tests import it from here
except NameError:
def cmp(lhs, rhs): # pylint:disable=redefined-builtin
if lhs is None:
if rhs is None:
return 0
else:
return -1
elif rhs is None:
return 1
def cmp(lhs, rhs):
if lhs is None:
if rhs is None:
return 0
else:
return (lhs > rhs) - (rhs > lhs)
return -1
elif rhs is None:
return 1
else:
return (lhs > rhs) - (rhs > lhs)


class _Smallest:
Expand Down Expand Up @@ -173,8 +170,8 @@ def sort(sequence, sort=(), _=None, mapping=0):
bytes,
int,
float,
type(()),
type([]),
tuple,
list,
type(None)
)

Expand All @@ -188,7 +185,7 @@ def strcoll_nocase(str1, str2):


_SORT_FUNCTIONS = {
"cmp": cmp, # builtin
"cmp": cmp,
"nocase": nocase,
"locale": strcoll,
"strcoll": strcoll,
Expand Down

0 comments on commit 04bf2b4

Please sign in to comment.