Commit 9a0acc05 authored by Stefan Behnel's avatar Stefan Behnel

Fix compiler crash on an assertion that had better been a safety condition.

Closes #2096.
parent 34b81d54
......@@ -2297,10 +2297,11 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
arg_count = len(arg_list)
if is_unbound_method or arg_count >= 3 or not (function.is_attribute and function.is_py_attr):
return node
if not function.obj.type.is_builtin_type:
return node
if function.obj.type.name in ('basestring', 'type'):
# these allow different actual types => unsafe
return node
assert function.obj.type.is_builtin_type
return ExprNodes.CachedBuiltinMethodCallNode(
node, function.obj, attr_name, arg_list)
......
......@@ -55,6 +55,26 @@ def str_endswith(str s, sub, start=None, stop=None):
return s.endswith(sub, start, stop)
def object_as_name(object):
"""
>>> object_as_name('abx')
True
>>> object_as_name('abc')
False
"""
return object.endswith("x")
def str_as_name(str):
"""
>>> str_as_name('abx')
True
>>> str_as_name('abc')
False
"""
return str.endswith("x")
@cython.test_assert_path_exists(
"//SimpleCallNode",
"//SimpleCallNode//NoneCheckNode",
......
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