possible to get rid of longjmp and setjmp?

36 views
Skip to first unread message

illume

unread,
Feb 24, 2009, 5:03:51 AM2/24/09
to tinypy
hi,

setjmp and longjmp cause super sad panda misery for me.

They make it hard to use threads with tinypy, and also cause troubles
with cpython ctypes... and I can imagine, it'd make it harder to embed
tinypy in some systems too.

They are currently used for exception handling, but maybe we can do
exception handling a different way?

Maybe we could take some inspiration from python exceptions?
http://docs.python.org/c-api/exceptions.html


cheers,

Harry Roberts

unread,
Feb 24, 2009, 9:15:47 AM2/24/09
to tin...@googlegroups.com
Aww, nobody wants a sad panda.

Anyway, yes it's possible to remove setjmp/longjmp stuff as long as
the status of `tp->ex` is checked after each tp_call (or anything else
that could invoke an exception) and then manually call tp_handle.

This could be done at the end of tp_step I suppose, and you'd have to
modify _tp_run to exit gracefully...

tp_handle could be yanked out too, allowing anybody to write their on handler?

Regards,
- Harry Roberts

2009/2/24 illume <ren...@gmail.com>:

illume

unread,
Feb 26, 2009, 6:50:42 PM2/26/09
to tinypy
Cool.


We could maybe have a little wrapper function/macro...

tp_chk(tp_call());

Which would check the error conditions, call tp_handle and return from
the current function if there was a problem.

There's 71 tp_raise calls in tinypy that I could find.


Is that the least intrusive way to do it?




On Feb 25, 1:15 am, Harry Roberts <harry.robe...@midnight-labs.org>
wrote:

Donny Viszneki

unread,
Mar 24, 2009, 9:40:39 AM3/24/09
to tinypy
On Feb 24, 6:03 am, illume <ren...@gmail.com> wrote:
> setjmp and longjmp cause super sad panda misery for me.

Hi everyone, I'm new to tinypy, just heard of it on the SWIG mailing
list, and it sounds completely awesome! (I have always been enamored
with the Lua VM, but I hate the Lua language, love Python, and have
always wanted the sandboxing features I have read tinypy has!

Being a newb, I am inclined to ask this: I read that tinypy is
stackless -- so why does would it need to use setjmp/longjmp for
*anything*?

Donny Viszneki

unread,
Mar 24, 2009, 10:49:48 AM3/24/09
to tinypy
Looking more closely, it looks like tinypy is *not* stackless, it just
has a separate C stack! What gives! You can't call this stackless!

Donny Viszneki

unread,
Mar 24, 2009, 11:00:53 AM3/24/09
to tinypy
On Mar 24, 10:49 am, Donny Viszneki <donny.viszn...@gmail.com> wrote:
> Looking more closely, it looks like tinypy is *not* stackless, it just
> has a separate C stack! What gives! You can't call this stackless!

What am I thinking? Please disregard...
Reply all
Reply to author
Forward
0 new messages