[gnome-continuous-yocto/gnomeostree-3.28-rocko: 697/8267] dirsize: python3: fix TypeError: unorderable types
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-continuous-yocto/gnomeostree-3.28-rocko: 697/8267] dirsize: python3: fix TypeError: unorderable types
- Date: Sat, 16 Dec 2017 20:47:24 +0000 (UTC)
commit f1e85d476030b83a748f0d70da5570e28dd8ac0d
Author: Ed Bartosh <ed bartosh linux intel com>
Date: Thu Jun 2 13:12:59 2016 +0300
dirsize: python3: fix TypeError: unorderable types
Python 3 ignores the __cmp__() method and doesn't have cmp() builtin
function. This caused sorted() call to raise
TypeError: unorderable types: Record() < Record()
Removing __cmp__ method and implementing __lt__ should solve the
problem as __lt__ is the only method needed for sort[ed] to work.
(From OE-Core rev: 391cd33720e7d7e8e261193199272739293ad881)
Signed-off-by: Ed Bartosh <ed bartosh linux intel com>
Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>
scripts/tiny/dirsize.py | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)
---
diff --git a/scripts/tiny/dirsize.py b/scripts/tiny/dirsize.py
index 5329b86..0b4fbd1 100755
--- a/scripts/tiny/dirsize.py
+++ b/scripts/tiny/dirsize.py
@@ -52,20 +52,16 @@ class Record:
self.size = 0
self.records = []
- def __cmp__(this, that):
+ def __lt__(this, that):
if that is None:
- return 1
+ return False
if not isinstance(that, Record):
raise TypeError
if len(this.records) > 0 and len(that.records) == 0:
- return -1
- if len(this.records) == 0 and len(that.records) > 0:
- return 1
- if this.size < that.size:
- return -1
+ return False
if this.size > that.size:
- return 1
- return 0
+ return False
+ return True
def show(self, minsize):
total = 0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]