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:
parent
8137e6ce6b
commit
f2274bd730
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user