From 660b4233aaa8636dd088ffa5b8ed5ebb29b5112b Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 16 Apr 2019 17:53:15 -0400 Subject: [PATCH] py3: remove unneeded use of cmp No need to carry around a polyglot implementation of cmp here, when sort(key=) works too. Fixes unnoticed error due to .sort(function) being implied as cmp= on python2, and not being permitted a positional argument on python3. --- src/calibre/ebooks/snb/snbfile.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/calibre/ebooks/snb/snbfile.py b/src/calibre/ebooks/snb/snbfile.py index 5a09652ccf..34c07a0cb0 100644 --- a/src/calibre/ebooks/snb/snbfile.py +++ b/src/calibre/ebooks/snb/snbfile.py @@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en' import sys, struct, zlib, bz2, os from calibre import guess_type -from polyglot.builtins import unicode_type, cmp +from polyglot.builtins import unicode_type class FileStream: @@ -17,10 +17,6 @@ class FileStream: return self.attr & 0x41000000 != 0x41000000 -def compareFileStream(file1, file2): - return cmp(file1.fileName, file2.fileName) - - class BlockData: pass @@ -200,7 +196,7 @@ class SNBFile: # Sort the files in file buffer, # requried by the SNB file format - self.files.sort(compareFileStream) + self.files.sort(key=lambda x: x.fileName) outputFile = open(outputFile, 'wb') # File header part 1