<?xml version="1.0" ?><html>
<head>
<title></title>
</head>
<body>
<div align="left"><font face="Arial"><span style="font-size:10pt">On 29 Jan 2005 at 23:34, Yann Vernier wrote:</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> On Sun, Jan 30, 2005 at 09:28:03AM +1100, sjmachin@lexicon.net wrote:</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > On 30 Jan 2005 at 9:58, Greg Ewing wrote:</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > > sjmachin@lexicon.net wrote:</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > > > Where I'm coming from is (my belief/understanding) that a "Python
function" hand </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > > > coded in C _should_ return NULL in this circumstance, so that the precise
exception set </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > > > by the called function can be thrown, instead of a guess.</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > > </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > > Oh, I see what you mean. Yes, that's what you would do</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > > if you were writing an extension module in C by hand.</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > > But in Pyrex you just use a "raise" statement, and</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > > Pyrex takes care of returning the NULL.</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > Apparently not: as one might expect, it generates code to do what Python does with
a </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > bare "raise" statement -- i.e. *RE*raise an already raised exception.</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > In my scenario, PyString_AsStringAndSize has *set* an exception, but it has not yet </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > been raised; we need to return NULL back down the call chain until the exception
is </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> > raised.</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> </span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> That's what the cdef function() except NULL form is for, isn't it? This</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> makes Pyrex check for exceptions when the function returns the indicated</span></font></div>
<div align="left"><font face="Arial" color="#7f0000"><span style="font-size:10pt">> value, if I understood the docs correctly.</span></font></div>
<div align="left"><br/></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">I see no cdef here.</span></font></div>
<div align="left"><br/></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">From my sample code:</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Courier New"><span style="font-size:10pt">def tester(s):</span></font></div>
<div align="left"></div>
</body>
</html>