From 55cf301b93b757e29b62932b5cc44df0e5026bae Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Fri, 29 Aug 2008 22:44:11 +0200 Subject: [PATCH] Fixed gcc warning with list comprehensions Ticket 65 --- Cython/Compiler/ExprNodes.py | 2 +- tests/run/listcomp.pyx | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/run/listcomp.pyx diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 1fd34af6..703e1980 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -2619,7 +2619,7 @@ class ListComprehensionAppendNode(ExprNode): self.is_temp = 1 def generate_result_code(self, code): - code.putln("%s = PyList_Append(%s, %s); %s" % + code.putln("%s = PyList_Append(%s, (PyObject*)%s); %s" % (self.result_code, self.target.result_code, self.expr.result_code, diff --git a/tests/run/listcomp.pyx b/tests/run/listcomp.pyx new file mode 100644 index 00000000..a63521fe --- /dev/null +++ b/tests/run/listcomp.pyx @@ -0,0 +1,16 @@ +u""" +>>> smoketest() +[0, 4, 8] +>>> typed() +[A, A, A] +""" + +def smoketest(): + print [x*2 for x in range(5) if x % 2 == 0] + +cdef class A: + def __repr__(self): return "A" + +def typed(): + cdef A obj + print [obj for obj in [A(), A(), A()]] \ No newline at end of file -- 2.26.2