[Pyrex] Total newbie needs code review

Chris Stromberger chris.stromberger at gmail.com
Fri Sep 9 14:49:32 CEST 2005


On 9/8/05, Grant McDonald <gmcdonald at infocomp.com> wrote:


> raising string exceptions is deprecated and will be removed in python 3. The
> preferred method of raising exceptions is: 
> 
>         raise ExceptionClass(*args **kwargs) 
> 
> so your call should be: 
> 
>         raise Exception("init failed, returned %d" % ret) 
> 
> or preferably define your own exception as a trivial subclass of Exception
> giving it a more meaningful name. 
> 

Thanks for the info.

> Second, be aware that when assigning python strings to char pointers in
> Pyrex the reference returned points to the memory where the python string is
> stored. This memory should not be modified external to calls using the
> python/c api so any functions that modify it must malloc the string pointer
> and copy the python string into it instead. 

Could you give an example of code using my example that would cause
issues?  I'm not clear on this bit.

Thanks for the input.

-Chris



More information about the Pyrex mailing list