1
0
mirror of https://github.com/myhdl/myhdl.git synced 2024-12-14 07:44:38 +08:00

replace __nonzero__ with __bool__

python3 deprecates __nonzero__ and introduces __bool__
This commit introduces __bool__ while maintaining python2 compatibility
This commit is contained in:
Keerthan Jaic 2015-03-09 13:39:18 -04:00
parent 8137e6ce6b
commit f2274bd730
2 changed files with 8 additions and 10 deletions

View File

@ -323,11 +323,10 @@ class _Signal(object):
raise TypeError("Signals are unhashable")
def __nonzero__(self):
if self._val:
return 1
else:
return 0
def __bool__(self):
return bool(self._val)
__nonzero__ = __bool__
# length
def __len__(self):

View File

@ -114,11 +114,10 @@ class intbv(object):
return iter([self[i] for i in range(self._nrbits-1, -1, -1)])
# logical testing
def __nonzero__(self):
if self._val:
return 1
else:
return 0
def __bool__(self):
return bool(self._val)
__nonzero__ = __bool__
# length
def __len__(self):