[Cython] strange bug in starred target

Robert Bradshaw robertwb at math.washington.edu
Thu Mar 3 21:49:42 CET 2011


On Thu, Mar 3, 2011 at 11:44 AM, Vitja Makarov <vitja.makarov at gmail.com> wrote:
> 2011/3/3 Vitja Makarov <vitja.makarov at gmail.com>:
>> 2011/3/3 Vitja Makarov <vitja.makarov at gmail.com>:
>>> This doesn't work:
>>> def assign():
>>>    a, *b = 1,2,3,4,5
>>>    return a, b
>>>
>>>>>> import x
>>>>>> x.assign()
>>> Traceback (most recent call last):
>>>  File "<stdin>", line 1, in <module>
>>>  File "x.pyx", line 6, in x.assign (x.c:445)
>>>    a, *b = 1,2,3,4,5
>>> TypeError: Expected list, got int
>>>
>>> And this is ok:
>>>
>>> def assign():
>>>    a, *b = 1,2,3,4,5
>>>    return a, b
>>>    *a, b = 1,2,3,4,5
>>>    return a, b
>>>
>>>>>> import x
>>>>>> x.assign()
>>> (1, [2, 3, 4, 5])
>>>
>>>
>>
>> I hope problem is somewhere in map_starred_assignment()
>>
>
> That wasn't as simple as patch is...
>
> Ticket on trac http://trac.cython.org/cython_trac/ticket/664
> Pull request https://github.com/cython/cython/pull/7

Thanks. Merged.

- Robert


More information about the cython-devel mailing list