From 4fa56fe2f8618f5fbc47ec21ac033d5e7ac2790d Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Sat, 26 Jan 2019 10:51:29 +0000 Subject: python: Add __bool__ helpers in addition to __nonzero__ Python 3 uses __bool__ instead of __nonzero__ when performing a Boolean comparison. Change-Id: I85185bbe136ecae67346fa23569e24edd7329222 Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/15996 Reviewed-by: Nikos Nikoleris --- src/python/m5/params.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/python/m5/params.py') diff --git a/src/python/m5/params.py b/src/python/m5/params.py index 09aaa5af7..b5de6ef6d 100644 --- a/src/python/m5/params.py +++ b/src/python/m5/params.py @@ -829,9 +829,12 @@ class Bool(ParamValue): # implement truth value testing for Bool parameters so that these params # evaluate correctly during the python configuration phase - def __nonzero__(self): + def __bool__(self): return bool(self.value) + # Python 2.7 uses __nonzero__ instead of __bool__ + __nonzero__ = __bool__ + def ini_str(self): if self.value: return 'true' -- cgit v1.2.3