Re: [Shedskin-list] suggestion? no such class: 'OverflowError'

0 views
Skip to first unread message

Jeff Hinrichs - DM&T

unread,
Jan 14, 2008, 8:54:27 AM1/14/08
to Mark Dufour, shedsk...@lists.sourceforge.net, shedskin...@googlegroups.com
On 1/14/08, Mark Dufour <mark....@gmail.com> wrote:
> On Jan 13, 2008 11:17 PM, Jeff Hinrichs - DM&T <je...@dundeemt.com> wrote:
> > I am attempting to see if I can build the mpmath module with shedskin.
> > http://code.google.com/p/mpmath/
>
> thanks for trying. how large is this module? note that it can be
> useful to look at one or a few functions at a time, instead of trying
> to compile it all..

.:
apps __init__.py lib mptypes.py tests
(711 lines of code)

./apps:
extrafun.py __init__.py interval.py pidigits.py quad.py taylordemo.py
(963 lines of code)

./lib:
complexop.py constants.py floatop.py functions.py __init__.py
numerals.py squareroot.py util.py
(1751 lines of code)

./tests:
benchmark.py test_bitwise.py test_convert.py
test_functions2.py test_interval.py test_power.py test_special.py
runtests.py test_compatibility.py test_division.py test_hp.py
test_mpmath.py test_quad.py

>
> > *ERROR* floatop:282: no such class: 'OverflowError'
>
> I haven't had the time to figure out how to properly support
> OverflowError and ZeroDivisionError.. if anyone is interested.. ^^
>
> > Any ideas on how I could work around this?
>
> just for testing purposes, you can add OverflowError to
> lib/builtin.py, so you can at least generate C++ code.
>
>
> mark.
> --
> "One of my most productive days was throwing away 1000 lines of code"
> - Ken Thompson
>


-jeff
p.s. I've cc'd the new google group too.

Mark Dufour

unread,
Jan 15, 2008, 6:18:05 AM1/15/08
to Jeff Hinrichs - DM&T, shedsk...@lists.sourceforge.net, shedskin...@googlegroups.com
> *ERROR* floatop:282: no such class: 'OverflowError'

I had a look at supporting OverflowError and ZeroDivisionError, and
apparently C++ has no provision for this.. I think the following might
work, then.. also in nested situations (the inner catch is found).

#include <signal.h>
#include <setjmp.h>

jmp_buf context;

void problem(int sig) {
longjmp(context, sig);
}

int main() {
int a = 0;
int b = 20;
int c;
int i;

signal(SIGFPE, problem);

try {
if ((i=setjmp(context)) == 0)
{
while(1)
c = b/a;
}
else
throw i;

} catch (int) {
printf("exception.. %d\n", i);

Reply all
Reply to author
Forward
0 new messages