From: Joe Guo Date: Mon, 30 Jul 2018 02:13:14 +0000 (+1200) Subject: python3: reuse cmp_fn defined in compat.py X-Git-Tag: tdb-1.3.17~2141 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd3b06fab0a3b5ac0730f8d025b7f20fdf1b3b30;p=thirdparty%2Fsamba.git python3: reuse cmp_fn defined in compat.py This will also fix PEP8 E306: expected 1 blank line before a nested definition, found 0 Signed-off-by: Joe Guo Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/upgradehelpers.py b/python/samba/upgradehelpers.py index 5e5655d74a2..7c0dbac2d56 100644 --- a/python/samba/upgradehelpers.py +++ b/python/samba/upgradehelpers.py @@ -28,6 +28,7 @@ import re import shutil import samba +from samba.compat import cmp_fn from samba import Ldb, version, ntacls from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE import ldb @@ -283,9 +284,8 @@ def dn_sort(x, y): len1 = len(tab1)-1 len2 = len(tab2)-1 # Note: python range go up to upper limit but do not include it - cmp = lambda x, y: (x > y) - (x < y) # cmp is removed in py3 for i in range(0, minimum): - ret = cmp(tab1[len1-i], tab2[len2-i]) + ret = cmp_fn(tab1[len1-i], tab2[len2-i]) if ret != 0: return ret else: