Commit 91d85432 authored by Stefan Behnel's avatar Stefan Behnel

fix unused access to optimise builtin methods which could lead to invalid C code being generated

parent 390d3af5
......@@ -5135,8 +5135,13 @@ class AttributeNode(ExprNode):
return "((struct %s *)%s%s%s)->%s" % (
obj.type.vtabstruct_cname, obj_code, self.op,
obj.type.vtabslot_cname, self.member)
else:
elif self.result_is_used:
return self.member
# Generating no code at all for unused access to optimised builtin
# methods fixes the problem that some optimisations only exist as
# macros, i.e. there is no function pointer to them, so we would
# generate invalid C code here.
return
elif obj.type.is_complex:
return "__Pyx_C%s(%s)" % (self.member.upper(), obj_code)
else:
......
......@@ -4,6 +4,7 @@ cimport cython
_set = set # CPython may not define it (in Py2.3), but Cython does :)
def test_set_clear_bound():
"""
>>> type(test_set_clear_bound()) is _set
......@@ -19,6 +20,7 @@ def test_set_clear_bound():
text = u'ab jd sdflk as sa sadas asdas fsdf '
pipe_sep = u'|'
@cython.test_assert_path_exists(
"//SimpleCallNode",
"//SimpleCallNode//NameNode")
......@@ -34,3 +36,17 @@ def test_unicode_join_bound(unicode sep, l):
"""
join = sep.join
return join(l)
def test_unicode_join_bound_no_assignment(unicode sep):
"""
>>> test_unicode_join_bound_no_assignment(text)
"""
sep.join
def test_dict_items_bound_no_assignment(dict d):
"""
>>> test_dict_items_bound_no_assignment({1:2})
"""
d.items
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