[Cython] Redundant Cython exception message strings

Stefan Behnel stefan_ml at behnel.de
Sat May 28 18:21:37 CEST 2011


Robert Bradshaw, 28.05.2011 18:14:
> On Sat, May 28, 2011 at 1:15 AM, Vitja Makarov wrote:
>> So maybe I should add functions like __Pyx_RaiseUnboundLocalError and
>> __Pyx_RaiseClosureNameError that will  use 3) way.
>> How do you like put_error_if_unbound CCodeWriter method is that right
>> place for it?
>
> I don't think abstracting it out to a function really saves anything
> here given that Python already has PyErr_Format.

Agreed. The existing functions are only there because they are used in 
multiple places, and usually receive formatting arguments. So putting them 
into one function makes it easier to keep the message consistent etc.

I also checked that even if you only call PyErr_Format() with multiple 
constant string arguments, without going through a function that explicitly 
declares them "const char*", gcc considers them "const char*" automatically 
and reuses the same constant in different places.

Stefan


More information about the cython-devel mailing list