[Python-Dev] Stackless Python (original) (raw)

"Martin v. Löwis" martin at v.loewis.de
Mon May 31 17:25:12 EDT 2004


Bob Ippolito wrote:

I'm believe that map and filter are non-recursive

Can you point me to the code that demonstrates this? Looking at Stackless' src/Python/bltinmodule.c:builtin_map, I see

     for (i = 0; ; ++i) {
    ...
             value = PyEval_CallObject(func, alist);
             ...
    PyList_SetItem(result, i, value)
    ...
}

which looks recursive to me.

I am not sure about unicode encode/decode. I don't think it's very common to do a tasklet switch in the middle of a unicode encode or decode, though :)

I thought Stackless was not only about tasklet switching, but also about running without stack... Wouldn't it perform the "hard" switching if the stack is running too deep?

Py-func1() -> C-func1() -> Py-func2() -> switch to new tasklet Py-func3() -> C-func2() -> throw exception()

I don't see how it could cause problems unless this is valid: PyFunc1 -> CPlusPlusExceptionCatcher -> PyFunc2 -> CPlusPlusExceptionThrower -> throws exception()

It crashes in the process of throwing the exception - not because it finds no exception handler. It crashes because the internal data structures have been corrupted.

I should have better made this example:

Py-func1() -> C-func1() -> Py-func2() -> switch to new tasklet Py-func3() -> Exception-Catcher -> C-func2() -> throw exception()

If that is valid, how the heck does PyFunc2 get cleaned up? I have to admit that I'm not very familiar with C++'s implementation of exceptions.

Throwing exceptions through Python functions is not supported, indeed. However, I was trying to point out that the entire exception handling mechanism gets corrupted, even if there are valid handlers on the stack.

Regards, Martin



More information about the Python-Dev mailing list