Skip to content

Commit 3c8981e

Browse files
committed
1 parent 2d05582 commit 3c8981e

10 files changed

+12
-1
lines changed
647 Bytes
Binary file not shown.
647 Bytes
Binary file not shown.
647 Bytes
Binary file not shown.
721 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ def call_function(self, arg, args, kwargs):
774774
func = self.pop()
775775
if hasattr(func, "im_func"):
776776
# Methods get self as an implicit first parameter.
777-
if func.im_self:
777+
if func.im_self is not None:
778778
posargs.insert(0, func.im_self)
779779
# The first parameter must be the correct type.
780780
if not isinstance(posargs[0], func.im_class):

0 commit comments

Comments
 (0)