| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 09e6ad0 commit 0ae748d
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,7 @@ OBJS= \ | |||
| 41 | 41 | getplatform.o getversion.o graminit.o \ | |
| 42 | 42 | import.o importdl.o \ | |
| 43 | 43 | marshal.o modsupport.o mystrtoul.o \ | |
| 44 | - pythonrun.o \ | ||
| 44 | + pyfpe.o pythonrun.o \ | ||
| 45 | 45 | sigcheck.o structmember.o sysmodule.o \ | |
| 46 | 46 | traceback.o \ | |
| 47 | 47 | $(LIBOBJS) | |
@@ -107,6 +107,7 @@ marshal.o: marshal.c | |||
| 107 | 107 | memmove.o: memmove.c | |
| 108 | 108 | modsupport.o: modsupport.c | |
| 109 | 109 | mystrtoul.o: mystrtoul.c | |
| 110 | + pyfpe.o: pyfpe.c | ||
| 110 | 111 | pythonrun.o: pythonrun.c | |
| 111 | 112 | sigcheck.o: sigcheck.c | |
| 112 | 113 | strerror.o: strerror.c | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1621,6 +1621,7 @@ object *AccessError; | |||
| 1621 | 1621 | object *AttributeError; | |
| 1622 | 1622 | object *ConflictError; | |
| 1623 | 1623 | object *EOFError; | |
| 1624 | + object *FloatingPointError; | ||
| 1624 | 1625 | object *IOError; | |
| 1625 | 1626 | object *ImportError; | |
| 1626 | 1627 | object *IndexError; | |
@@ -1654,6 +1655,7 @@ initerrors() | |||
| 1654 | 1655 | AttributeError = newstdexception("AttributeError"); | |
| 1655 | 1656 | ConflictError = newstdexception("ConflictError"); | |
| 1656 | 1657 | EOFError = newstdexception("EOFError"); | |
| 1658 | + FloatingPointError = newstdexception("FloatingPointError"); | ||
| 1657 | 1659 | IOError = newstdexception("IOError"); | |
| 1658 | 1660 | ImportError = newstdexception("ImportError"); | |
| 1659 | 1661 | IndexError = newstdexception("IndexError"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -782,6 +782,7 @@ parsenumber(co, s) | |||
| 782 | 782 | extern double atof PROTO((const char *)); | |
| 783 | 783 | char *end; | |
| 784 | 784 | long x; | |
| 785 | + double dx; | ||
| 785 | 786 | #ifndef WITHOUT_COMPLEX | |
| 786 | 787 | Py_complex c; | |
| 787 | 788 | int imflag; | |
@@ -810,12 +811,18 @@ parsenumber(co, s) | |||
| 810 | 811 | #ifndef WITHOUT_COMPLEX | |
| 811 | 812 | if (imflag) { | |
| 812 | 813 | c.real = 0.; | |
| 814 | + PyFPE_START_PROTECT("atof", return 0) | ||
| 813 | 815 | c.imag = atof(s); | |
| 816 | + PyFPE_END_PROTECT | ||
| 814 | 817 | return newcomplexobject(c); | |
| 815 | 818 | } | |
| 816 | - else | ||
| 819 | + else { | ||
| 817 | 820 | #endif | |
| 818 | - return newfloatobject(atof(s)); | ||
| 821 | + PyFPE_START_PROTECT("atof", return 0) | ||
| 822 | + dx = atof(s); | ||
| 823 | + PyFPE_END_PROTECT | ||
| 824 | + return newfloatobject(dx); | ||
| 825 | + } | ||
| 819 | 826 | } | |
| 820 | 827 | ||
| 821 | 828 | static object * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -412,14 +412,18 @@ r_object(p) | |||
| 412 | 412 | { | |
| 413 | 413 | extern double atof PROTO((const char *)); | |
| 414 | 414 | char buf[256]; | |
| 415 | + double dx; | ||
| 415 | 416 | n = r_byte(p); | |
| 416 | 417 | if (r_string(buf, (int)n, p) != n) { | |
| 417 | 418 | err_setstr(EOFError, | |
| 418 | 419 | "EOF read where object expected"); | |
| 419 | 420 | return NULL; | |
| 420 | 421 | } | |
| 421 | 422 | buf[n] = '\0'; | |
| 422 | - return newfloatobject(atof(buf)); | ||
| 423 | + PyFPE_START_PROTECT("atof", return 0) | ||
| 424 | + dx = atof(buf); | ||
| 425 | + PyFPE_END_PROTECT | ||
| 426 | + return newfloatobject(dx); | ||
| 423 | 427 | } | |
| 424 | 428 | ||
| 425 | 429 | #ifndef WITHOUT_COMPLEX | |
@@ -435,15 +439,19 @@ r_object(p) | |||
| 435 | 439 | return NULL; | |
| 436 | 440 | } | |
| 437 | 441 | buf[n] = '\0'; | |
| 442 | + PyFPE_START_PROTECT("atof", return 0) | ||
| 438 | 443 | c.real = atof(buf); | |
| 444 | + PyFPE_END_PROTECT | ||
| 439 | 445 | n = r_byte(p); | |
| 440 | 446 | if (r_string(buf, (int)n, p) != n) { | |
| 441 | 447 | err_setstr(EOFError, | |
| 442 | 448 | "EOF read where object expected"); | |
| 443 | 449 | return NULL; | |
| 444 | 450 | } | |
| 445 | 451 | buf[n] = '\0'; | |
| 452 | + PyFPE_START_PROTECT("atof", return 0) | ||
| 446 | 453 | c.imag = atof(buf); | |
| 454 | + PyFPE_END_PROTECT | ||
| 447 | 455 | return newcomplexobject(c); | |
| 448 | 456 | } | |
| 449 | 457 | #endif | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + #include "config.h" | ||
| 2 | + #include "pyfpe.h" | ||
| 3 | + | ||
| 4 | + /* | ||
| 5 | + * The signal handler for SIGFPE is actually declared in an external | ||
| 6 | + * module fpectl, or as preferred by the user. These variable | ||
| 7 | + * definitions are required in order to compile Python without | ||
| 8 | + * getting missing externals, but to actually handle SIGFPE requires | ||
| 9 | + * defining a handler and enabling generation of SIGFPE. | ||
| 10 | + */ | ||
| 11 | + | ||
| 12 | + #ifdef WANT_SIGFPE_HANDLER | ||
| 13 | + jmp_buf PyFPE_jbuf; | ||
| 14 | + int PyFPE_counter = 0; | ||
| 15 | + double PyFPE_dummy(void){return(1.0);} | ||
| 16 | + #endif | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments