Commit 07629865 authored by Stefan Behnel's avatar Stefan Behnel

fix reversed order of operands in constant calculation for 'in' and 'not in' operator

parent e896d20f
...@@ -8219,9 +8219,6 @@ class TypeofNode(ExprNode): ...@@ -8219,9 +8219,6 @@ class TypeofNode(ExprNode):
# #
#------------------------------------------------------------------- #-------------------------------------------------------------------
def _not_in(x, seq):
return x not in seq
compile_time_binary_operators = { compile_time_binary_operators = {
'<': operator.lt, '<': operator.lt,
'<=': operator.le, '<=': operator.le,
...@@ -8243,8 +8240,8 @@ compile_time_binary_operators = { ...@@ -8243,8 +8240,8 @@ compile_time_binary_operators = {
'>>': operator.rshift, '>>': operator.rshift,
'-': operator.sub, '-': operator.sub,
'^': operator.xor, '^': operator.xor,
'in': operator.contains, 'in': lambda x, seq: x in seq,
'not_in': _not_in, 'not_in': lambda x, seq: x not in seq,
} }
def get_compile_time_binop(node): def get_compile_time_binop(node):
......
...@@ -131,3 +131,15 @@ def str_slicing2(): ...@@ -131,3 +131,15 @@ def str_slicing2():
str3 = 'abc\xE9def'[2:4] str3 = 'abc\xE9def'[2:4]
return str0, str1, str2, str3 return str0, str1, str2, str3
@cython.test_fail_if_path_exists(
"//IfStatNode",
)
def str_in_and_not_in():
"""
>>> str_in_and_not_in()
True
"""
if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': return True
else: return False
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