Skip to content

Commit 165b87c

Browse files
committed
1 parent 2d05582 commit 165b87c

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed
647 Bytes
Binary file not shown.
647 Bytes
Binary file not shown.
647 Bytes
Binary file not shown.
805 Bytes
Binary file not shown.
556 Bytes
Binary file not shown.
556 Bytes
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Falsy(object):
2+
def __bool__(self):
3+
return False
4+
__nonzero__ = __bool__
5+
def do_stuff(self):
6+
pass
7+
8+
Falsy().do_stuff()

test/test_basic.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def test_globals(self):
2626
def test_inplace_operators(self):
2727
self.do_one()
2828

29+
def test_bound_method_on_falsy_objects(self):
30+
self.do_one()
31+
2932
if PY2:
3033
def test_inplace_division(self):
3134
self.assert_ok("""\

xpython/pyvm2.py

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,20 @@ def __init__(self, python_version=PYTHON_VERSION):
6666
from xpython.byteop.byteop26 import ByteOp26
6767
self.byteop = ByteOp26(self)
6868
pass
69-
elif int_vers == 25:
70-
from xpython.byteop.byteop25 import ByteOp25
71-
self.byteop = ByteOp25(self)
72-
pass
7369
pass
7470
else:
7571
# 3.0 or greater
76-
if int_vers < 34:
77-
if int_vers == 32:
78-
from xpython.byteop.byteop32 import ByteOp32
79-
self.byteop = ByteOp32(self)
80-
elif int_vers == 33:
81-
from xpython.byteop.byteop33 import ByteOp33
82-
self.byteop = ByteOp33(self)
83-
else:
84-
self.byteop = None
72+
if int_vers == 33:
73+
from xpython.byteop.byteop33 import ByteOp33
74+
self.byteop = ByteOp33(self)
75+
elif int_vers == 34:
76+
from xpython.byteop.byteop34 import ByteOp34
77+
self.byteop = ByteOp34(self)
78+
elif int_vers == 35:
79+
from xpython.byteop.byteop35 import ByteOp35
80+
self.byteop = ByteOp35(self)
8581
else:
86-
if int_vers == 34:
87-
from xpython.byteop.byteop34 import ByteOp34
88-
self.byteop = ByteOp34(self)
89-
elif int_vers == 35:
90-
from xpython.byteop.byteop35 import ByteOp35
91-
self.byteop = ByteOp35(self)
92-
else:
93-
self.byteop = None
82+
self.byteop = None
9483

9584
def top(self):
9685
"""Return the value at the top of the stack, with no changes."""
@@ -735,7 +724,7 @@ def byte_SETUP_WITH(self, dest):
735724
## Functions
736725

737726
def byte_MAKE_CLOSURE(self, argc):
738-
if PYTHON_VERSION >= 3.3:
727+
if PYTHON3:
739728
# TODO: the py3 docs don't mention this change.
740729
name = self.pop()
741730
else:
@@ -774,7 +763,7 @@ def call_function(self, arg, args, kwargs):
774763
func = self.pop()
775764
if hasattr(func, "im_func"):
776765
# Methods get self as an implicit first parameter.
777-
if func.im_self:
766+
if func.im_self is not None:
778767
posargs.insert(0, func.im_self)
779768
# The first parameter must be the correct type.
780769
if not isinstance(posargs[0], func.im_class):

0 commit comments

Comments
 (0)