Commit 519c1fff authored by Stefan Behnel's avatar Stefan Behnel

avoid borrowed references with PyPy in fast list/tuple iteration code

parent 8b4a6e20
...@@ -2055,6 +2055,7 @@ class IteratorNode(ExprNode): ...@@ -2055,6 +2055,7 @@ class IteratorNode(ExprNode):
inc_dec = '--' inc_dec = '--'
else: else:
inc_dec = '++' inc_dec = '++'
code.putln("#if CYTHON_COMPILING_IN_CPYTHON")
code.putln( code.putln(
"%s = Py%s_GET_ITEM(%s, %s); __Pyx_INCREF(%s); %s%s;" % ( "%s = Py%s_GET_ITEM(%s, %s); __Pyx_INCREF(%s); %s%s;" % (
result_name, result_name,
...@@ -2064,6 +2065,16 @@ class IteratorNode(ExprNode): ...@@ -2064,6 +2065,16 @@ class IteratorNode(ExprNode):
result_name, result_name,
self.counter_cname, self.counter_cname,
inc_dec)) inc_dec))
code.putln("#else")
code.putln(
"%s = PySequence_ITEM(%s, %s); %s%s; %s;" % (
result_name,
self.py_result(),
self.counter_cname,
self.counter_cname,
inc_dec,
code.error_goto_if_null(result_name, self.pos)))
code.putln("#endif")
def generate_iter_next_result_code(self, result_name, code): def generate_iter_next_result_code(self, result_name, code):
sequence_type = self.sequence.type sequence_type = self.sequence.type
......
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