[Cython] Cython 0.21 released

Stefan Behnel stefan_ml at behnel.de
Sat Oct 11 16:53:05 CEST 2014


Yaroslav Halchenko schrieb am 11.10.2014 um 16:18:
> On Wed, 10 Sep 2014, Stefan Behnel wrote:
>> on behalf of the Cython dev team, I'm pleased to announce the release of
>> Cython 0.21, a major feature release. Thanks everyone who contributed code,
>> documentation improvements, test feedback, bug reports and/or otherwise
>> helpful insights for this release.
> 
> a little change detected while down-stream testing builds in Debian
> (previous version was 0.20.2 and it built fine)
> 
>  ------------------------------------------------------------
>  ...
>              vertex_format.last_shader = self
>              for i in xrange(vertex_format.vattr_count):
>                  attr = &vertex_format.vattr[i]
>                  if attr.per_vertex == 0:
>                      continue
>                  attr.index = glGetAttribLocation(self.program, <char *><bytes>attr.name)
>                                                                ^
>  ------------------------------------------------------------
>  
>  kivy/graphics/shader.pyx:448:63: Casting temporary Python object to non-numeric non-Python type

Wow, interesting piece of code. What's that even supposed to do?

Looking up their code, I find that "attr.name" is a char*:

https://github.com/kivy/kivy/blob/master/kivy/graphics/vertex.pxd

So the above code creates a temporary Python bytes object by copying data
from a char*, then gets the char* to the internal object buffer and throws
the object away, thus deleting its buffer. Then it passes that invalidated
char* into a function. I can't see how this makes any sense. And I'm happy
to see that Cython catches this kind of bug now.


> I wondered if that is an intentional restriction now to restrict such casting
> only to numeric (and exclude the simplest form -- bytes/chars) or a
> regression?

It seems they fixed their code already:

https://github.com/kivy/kivy/commit/827bd6c7b7d04ec72cb3bdbf0ffcd90630d90008

Stefan



More information about the cython-devel mailing list