From d660c8d8f3e7f8067f2dc3224c688844b662c233 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 19 Jun 2019 10:17:21 -0700 Subject: [PATCH] releasetools: Make rangelib Python 3 compatibile. Bug: 131631303 Test: `python -m unittest test_rangelib` Test: `python3 -m unittest test_rangelib` Change-Id: Ia8e26623d5967f2eea003252ee56b861350d626b --- tools/releasetools/rangelib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/releasetools/rangelib.py b/tools/releasetools/rangelib.py index 36becf419..9d6e9fb17 100644 --- a/tools/releasetools/rangelib.py +++ b/tools/releasetools/rangelib.py @@ -52,9 +52,12 @@ class RangeSet(object): def __ne__(self, other): return self.data != other.data - def __nonzero__(self): + def __bool__(self): return bool(self.data) + # Python 2 uses __nonzero__, while Python 3 uses __bool__. + __nonzero__ = __bool__ + def __str__(self): if not self.data: return "empty"