[Sugar-devel] [PATCH sugar] don't choke on out-of-range times on FAT32 formatted media

Sascha Silbe sascha-pgp at silbe.org
Fri Jan 21 10:15:15 EST 2011


From: Kenny Meyer <knny.myer at gmail.com>

Files on a FAT32 formatted USB stick apparently can have times that get
represented as negative Unix timestamps large enough to overflow the (32-bit)
int. Python will automatically cast the subtraction result to long, but only
accepts int from the comparison function (list.sort()). The resulting
exception messes up the Journal.

Using cmp instead of subtraction avoids this issue.

Reported-By: Bernie Innocenti <bernie at sugarlabs.org>
[changed description]
Signed-off-by: Sascha Silbe <sascha-pgp at silbe.org>
Reviewed-by: Sascha Silbe <sascha-pgp at silbe.org>
---
 src/jarabe/journal/model.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index 9ab8c5e..320e577 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -274,7 +274,7 @@ class InplaceResultSet(BaseResultSet):
         else:
             # timestamp
             keygetter = itemgetter(2)
-        self._file_list.sort(lambda a, b: b - a,
+        self._file_list.sort(lambda a, b: cmp(b, a),
                              key=keygetter,
                              reverse=(self._sort[0] == '-'))
         self.ready.send(self)
-- 
1.7.2.3



More information about the Sugar-devel mailing list