Stefan Behnel wrote:
> [replying to myself...]
> 
> Stefan Behnel wrote:
>> When I add DECREF cleanup code to the return statement, the test suite
>> passes just like before
> 
> and in fact, the code that the iter-dict transform generates for ticket
> #124 shows that this is required. For this code
> 
>     def spam(dict d):
>         for elm in d:
>             return False
>         return True
> 
> Cython now generates this when I add DEFREF cleanup code for new-style
> temps to the return statement:
> 

snip

> Note the line where it says "Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;", which
> wasn't there before.

OK I thought of something that might be an issue. Psuedo-code:

tempsblocknode t1 = 3:
     try:
         try:
             tempsblocknode t2 = 4:
                 return False
         finally:
             print t1
     finally:
         print t1

Is it enough just to document that TempsBlockNode must not be used in 
such a way that the temp can be accessed within a finally clause? 
(Python already helps us here by disallowing "continue" within finally, 
for instance). I suppose this is usually under strict control of the 
transform using TempsBlockNode.

Otherwise it looks like solving this involves some (not too advanced) 
kind of flow control analysis, in a transform tracking TempsBlockNodes 
and try/finally-nodes.

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to