Commit 6c30dd84 authored by Stefan Behnel's avatar Stefan Behnel

fix in-test when RHS needs coercion from non-Python type

parent d887dac9
......@@ -8741,7 +8741,9 @@ class CmpNode(object):
self.special_bool_cmp_utility_code = UtilityCode.load_cached("PyDictContains", "ObjectHandling.c")
self.special_bool_cmp_function = "__Pyx_PyDict_Contains"
return True
elif self.operand2.type.is_pyobject:
else:
if not self.operand2.type.is_pyobject:
self.operand2 = self.operand2.coerce_to_pyobject(env)
self.special_bool_cmp_utility_code = UtilityCode.load_cached("PySequenceContains", "ObjectHandling.c")
self.special_bool_cmp_function = "__Pyx_PySequence_Contains"
return True
......
......@@ -349,3 +349,30 @@ def constant_empty_sequence(a):
False
"""
return a in ()
def test_error_non_iterable(x):
"""
>>> test_error_non_iterable(1) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...iterable...
"""
return x in 42
def test_error_non_iterable_cascaded(x):
"""
>>> test_error_non_iterable_cascaded(1) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...iterable...
"""
return 1 == x in 42
def test_inop_cascaded(x):
"""
>>> test_inop_cascaded(1)
False
>>> test_inop_cascaded(2)
True
>>> test_inop_cascaded(3)
False
"""
return 1 != x in [2]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment