[Pyrex] Initialisation of cdef global arrays with constants [resend]

sjmachin at lexicon.net sjmachin at lexicon.net
Sat Jan 29 23:45:24 CET 2005


On 29 Jan 2005 at 23:34, Yann Vernier wrote:

> On Sun, Jan 30, 2005 at 09:28:03AM +1100, sjmachin at lexicon.net wrote:
> > On 30 Jan 2005 at 9:58, Greg Ewing wrote:
> > 
> > > sjmachin at lexicon.net wrote:
> > > > Where I'm coming from is (my belief/understanding) that a "Python function" hand 
> > > > coded in C _should_ return NULL in this circumstance, so that the precise exception set 
> > > > by the called function can be thrown, instead of a guess.
> > > 
> > > Oh, I see what you mean. Yes, that's what you would do
> > > if you were writing an extension module in C by hand.
> > > But in Pyrex you just use a "raise" statement, and
> > > Pyrex takes care of returning the NULL.
> > 
> > Apparently not: as one might expect, it generates code to do what Python does with a 
> > bare "raise" statement -- i.e. *RE*raise an already raised exception.
> > 
> > In my scenario, PyString_AsStringAndSize has *set* an exception, but it has not yet 
> > been raised; we need to return NULL back down the call chain until the exception is 
> > raised.
> 
> That's what the cdef function() except NULL form is for, isn't it? This
> makes Pyrex check for exceptions when the function returns the indicated
> value, if I understood the docs correctly.

I see no cdef here.

>From my sample code:

def tester(s):

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20050130/1ad28e45/attachment.html


More information about the Pyrex mailing list