From eb1e7173133a5dcc266203e8928c60b2e3b8446a Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 12 Apr 2013 11:20:35 +0200 Subject: [PATCH] fix cascaded assignments of None to extension type variables --- Cython/Compiler/Nodes.py | 11 ++++++----- tests/run/unpack.pyx | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index e1ce05e..6c14241 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -4573,11 +4573,12 @@ class CascadedAssignmentNode(AssignmentNode): from ExprNodes import CloneNode, ProxyNode self.rhs = self.rhs.analyse_types(env) - if use_temp or self.rhs.is_attribute: - # (cdef) attribute access is not safe as it traverses pointers - self.rhs = self.rhs.coerce_to_temp(env) - else: - self.rhs = self.rhs.coerce_to_simple(env) + # (cdef) attribute access is not safe as it traverses pointers + if self.rhs.is_attribute or not self.rhs.is_simple(): + if use_temp: + self.rhs = self.rhs.coerce_to_temp(env) + else: + self.rhs = self.rhs.coerce_to_simple(env) self.rhs = ProxyNode(self.rhs) self.coerced_rhs_list = [] diff --git a/tests/run/unpack.pyx b/tests/run/unpack.pyx index 0e06cb2..d568936 100644 --- a/tests/run/unpack.pyx +++ b/tests/run/unpack.pyx @@ -363,3 +363,27 @@ def unpack_many_int(it): cdef Py_ssize_t h a,b,c,d,e,f,g,h,i,j,k,l = it return a,b,c,d,e,f,g,h,i,j,k,l + + +def unpack_literal_none_to_builtin_type(): + """ + >>> unpack_literal_none_to_builtin_type() + (None, None, None, None) + """ + cdef list a,b,c,d + a, b = c, d = None, None + return a,b,c,d + + +cdef class ExtType: + pass + + +def unpack_literal_none_to_exttype(): + """ + >>> unpack_literal_none_to_exttype() + (None, None, None, None) + """ + cdef ExtType a,b,c,d + a, b = c, d = None, None + return a,b,c,d -- 2.7.4