Issue39

Title Need to keep references to local variables in case of exception raise
Priority bug Status resolved
Superseder Nosy List kayhayen
Assigned To kayhayen Keywords wrong_execution

Created on 2012-07-08.09:44:48 by kayhayen, last changed by kayhayen.

Messages
msg140 (view) Author: kayhayen Date: 2012-11-12.07:02:43
Released as part of 0.3.25 the other day
msg131 (view) Author: kayhayen Date: 2012-10-08.19:15:03
Because this is now open to a long time, the option to attach "locals()" to the 
frame raising the exception, and breaking its re-use has been chosen. It is 
dubious if the integrated solution could be more efficient at storing locals.

The locals attaching is not clever at all, and not limited to values with 
potential side effects. So will need more work before release to be more 
optimal, but it passed the test now.
msg123 (view) Author: kayhayen Date: 2012-08-26.09:25:14
Another idea, that I have mostly implemented is compiled frames. We are going to 
use our own type for "compiled frames", which then can be really good friend to 
local and closure variables, and integrate with them, without loosing 
performance.

These may then be attached to local variables, which will them keep the 
reference together with the frame.

This way, integration with CPython will only improve, caching of frames can
be even more effective, and if we manage cells to be reused too, it may even
be faster for closure variables.
msg106 (view) Author: kayhayen Date: 2012-07-08.09:56:50
I also noted that f_locals, currently gives "globals" instead, which is wrong as 
well and would need to be fixed.
msg105 (view) Author: kayhayen Date: 2012-07-08.09:54:34
I am contemplating several solutions. One is this.

Storage for local variables (with need for frames, i.e. those who raise 
exceptions) will be done in cell objects inside frames. These are created, when 
the frame is created, and they could be reused. 

The other is: When the frame exits with exception, it gets cells created and 
assigned. Reuse of the frame should be able to use that.

For compatibility, the former approach will give us a working f_locals, which is 
probably worth a lot by itself, if the overhead of cells is not too much. For 
performance, the second approach might be nicer, as it's only done in case the 
exception actually occurs.
msg104 (view) Author: kayhayen Date: 2012-07-08.09:44:48
The frames attached to raised exceptions to not hold references to the variables, 
instead the PyLocalVariable class does. It releases on exit.

In cases, where a frame leaves the current function due to an exception, that 
variable should still be held. It current is not correct.
History
Date User Action Args
2012-11-12 07:02:43kayhayensetstatus: testing -> resolved
messages: + msg140
2012-10-08 19:15:03kayhayensetstatus: in-progress -> testing
messages: + msg131
2012-08-26 09:25:14kayhayensetstatus: chatting -> in-progress
messages: + msg123
2012-07-08 09:56:50kayhayensetmessages: + msg106
2012-07-08 09:54:34kayhayensetmessages: + msg105
2012-07-08 09:44:48kayhayencreate