Skip to content

Commit 5de2ef5

Browse files
Daniel NunesInfernio
authored andcommitted
Prepare __nonzero__ for py3
1 parent 9364228 commit 5de2ef5

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

Mopy/bash/ScriptParser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def __rshift__(self, other): return Parser.Token(self.tkn >> other.tkn)
394394
def __and__(self, other): return Parser.Token(self.tkn & other.tkn)
395395
def __xor__(self, other): return Parser.Token(self.tkn ^ other.tkn)
396396
def __or__(self, other): return Parser.Token(self.tkn | other.tkn)
397-
def __nonzero__(self): return bool(self.tkn)
397+
def __bool__(self): return bool(self.tkn)
398398
def __neg__(self): return Parser.Token(-self.tkn)
399399
def __pos__(self): return Parser.Token(+self.tkn)
400400
def __abs__(self): return abs(self.tkn)
@@ -407,6 +407,9 @@ def __repr__(self): return u'<Token-%s:%s>' % (Types[self.type],self.text)
407407
# Fall through to function/keyword
408408
def __call__(self, *args, **kwdargs): return self.tkn(*args, **kwdargs)
409409

410+
# PY3 get rid of this once we port
411+
__nonzero__ = __bool__
412+
410413

411414
# Now for the Parser class
412415
def __init__(self,

Mopy/bash/cint.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,10 @@ def __ne__(self, other):
736736
try: return other[1] != self.formID[1] or other[0] != self.formID[0]
737737
except TypeError: return False
738738

739-
def __nonzero__(self):
739+
def __bool__(self):
740740
return not isinstance(self.formID, (FormID.EmptyFormID, FormID.InvalidFormID))
741+
# PY3 get rid of this once we port
742+
__nonzero__ = __bool__
741743

742744
def __getitem__(self, x):
743745
return self.formID[0] if x == 0 else self.formID[1]
@@ -973,8 +975,10 @@ def __ne__(self, other):
973975
try: return other[1] != self.actorValue[1] or other[0] != self.actorValue[0]
974976
except TypeError: return False
975977

976-
def __nonzero__(self):
978+
def __bool__(self):
977979
return not isinstance(self.actorValue, (ActorValue.EmptyActorValue, ActorValue.InvalidActorValue))
980+
# PY3 get rid of this once we port
981+
__nonzero__ = __bool__
978982

979983
def __getitem__(self, x):
980984
return self.actorValue[0] if x == 0 else self.actorValue[1]
@@ -1221,8 +1225,10 @@ def __eq__(self, other):
12211225
def __ne__(self, other):
12221226
return other[1] != self.mgefCode[1] or other[0] != self.mgefCode[0]
12231227

1224-
def __nonzero__(self):
1228+
def __bool__(self):
12251229
return not isinstance(self.mgefCode, (MGEFCode.EmptyMGEFCode, MGEFCode.InvalidMGEFCode))
1230+
# PY3 get rid of this once we port
1231+
__nonzero__ = __bool__
12261232

12271233
def __getitem__(self, x):
12281234
return self.mgefCode[0] if x == 0 else self.mgefCode[1]

0 commit comments

Comments
 (0)