Stackless Python 1.0 + Continuations 0.6

mmillikan at vfa.com mmillikan at vfa.com
Mon Jan 31 10:09:03 EST 2000


Congratulations on 'stackless'!

There appears to be a problem in handling control flow in the
following class of constructs:

def stacklesstest():
    try:
        return 45
	print 'still here' #not printed (correct)
    finally:
        print 'in finally' #printed (correct)
    return 'x = 99'

standard 'CPython' execution:

C:\WebSite102\bin>python -i I:\_members\mark\p5\experimental\stacktest.py
>>> x = stacklesstest()
in finally
>>> x
45
>>>

JPython execution:

>>> ## working on region in file i:\_members\mark\p5\Experimental\python-BDAqVJ...
>>> x = stacklesstest()
in finally
>>> x
45
>>> 

'stackless' execution:

>>> ## working on region in file i:\_members\mark\p5\Experimental\python-BDAEqV...
>>> x = stacklesstest()
in finally
>>> x
'x = 99'
>>> 

The 'return' inside the 'try:' clause exits the 'try:' clause and
executes the 'finally:' clause as expected. However, the 'return' and
associated value is forgotten after the 'finally:' clause has
executed: the unnested 'return' is then executed before the function
returns.

The behaviour is the same in the following function with the
expicatory 'noise' removed.

def stacklesstest2():
    try:
        return 45
    finally:
        pass

This impacts some code in wxPython, possibly it also may be the cause
of the difficulties in Zope(?)






More information about the Python-list mailing list