New form of PyFPE_END_PROTECT macro.

This commit is contained in:
Guido van Rossum 1997-03-14 04:32:50 +00:00
parent 1aeb1047ba
commit 45b83915f8
12 changed files with 36 additions and 36 deletions

View File

@ -730,7 +730,7 @@ Tkapp_ExprDouble (self, args)
return NULL;
PyFPE_START_PROTECT("Tkapp_ExprDouble", return 0)
retval = Tcl_ExprDouble (Tkapp_Interp (self), s, &v);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(retval)
if (retval == TCL_ERROR)
return Tkinter_Error(self);
return Py_BuildValue("d", v);

View File

@ -249,7 +249,7 @@ math_1(args, func)
errno = 0;
PyFPE_START_PROTECT("complex function", return 0)
x = (*func)(x);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(x)
CHECK(x.real);
CHECK(x.imag);
if (errno != 0)

View File

@ -120,11 +120,11 @@ static double nest1(int i, double x)
/* This (following) message is never seen. */
PyFPE_START_PROTECT("Division by zero, inner zone", return 3.1416)
a = 1./(1. - x);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(a)
}else if(i == 2){
a = 1./(2. - x);
}
PyFPE_END_PROTECT
PyFPE_END_PROTECT(a)
return a;
}
@ -140,7 +140,7 @@ static double nest2(int i, double x)
}else if(i == 2){
a = 1./(2. - x);
}
PyFPE_END_PROTECT
PyFPE_END_PROTECT(a)
return a;
}
@ -150,7 +150,7 @@ static double nest3(double x)
/* This (following) message is never seen. */
PyFPE_START_PROTECT("Division by zero, nest3 error", return 3.1416)
result = 1./(1. - x);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(result)
return result;
}
@ -159,7 +159,7 @@ static double db0(double x)
double a;
PyFPE_START_PROTECT("Division by zero", return 3.1416)
a = 1./x;
PyFPE_END_PROTECT
PyFPE_END_PROTECT(a)
return a;
}
@ -168,7 +168,7 @@ static double overflow(double b)
double a;
PyFPE_START_PROTECT("Overflow", return 3.1416)
a = b*b;
PyFPE_END_PROTECT
PyFPE_END_PROTECT(a)
return a;
}

View File

@ -390,7 +390,7 @@ PyObject *args;
PyFPE_START_PROTECT("readscaled", return 0)
xfac = (float)xsize/(float)xwtd;
yfac = (float)ysize/(float)ywtd;
PyFPE_END_PROTECT
PyFPE_END_PROTECT(yfac)
cdatap = PyString_AsString(rv);
idatap = (long *)cdatap;

View File

@ -82,7 +82,7 @@ math_1(args, func)
errno = 0;
PyFPE_START_PROTECT("in math_1", return 0)
x = (*func)(x);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(x)
CHECK(x);
if (errno != 0)
return math_error();
@ -101,7 +101,7 @@ math_2(args, func)
errno = 0;
PyFPE_START_PROTECT("in math_2", return 0)
x = (*func)(x, y);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(x)
CHECK(x);
if (errno != 0)
return math_error();
@ -179,7 +179,7 @@ math_ldexp(self, args)
errno = 0;
PyFPE_START_PROTECT("ldexp", return 0)
x = ldexp(x, (int)y);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(x)
CHECK(x);
if (errno != 0)
return math_error();

View File

@ -1497,7 +1497,7 @@ mpz_float(self)
mulstate *= multiplier;
mpz_div_2exp(&mpzscratch, &mpzscratch, BITS_PER_MP_LIMB);
}
PyFPE_END_PROTECT
PyFPE_END_PROTECT(mulstate)
assert(mpz_cmp_ui(&mpzscratch, (unsigned long int)0) == 0);
mpz_clear(&mpzscratch);

View File

@ -367,7 +367,7 @@ complex_add(v, w)
Py_complex result;
PyFPE_START_PROTECT("complex_add", return 0)
result = c_sum(v->cval,w->cval);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(result)
return newcomplexobject(result);
}
@ -379,7 +379,7 @@ complex_sub(v, w)
Py_complex result;
PyFPE_START_PROTECT("complex_sub", return 0)
result = c_diff(v->cval,w->cval);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(result)
return newcomplexobject(result);
}
@ -391,7 +391,7 @@ complex_mul(v, w)
Py_complex result;
PyFPE_START_PROTECT("complex_mul", return 0)
result = c_prod(v->cval,w->cval);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(result)
return newcomplexobject(result);
}
@ -404,7 +404,7 @@ complex_div(v, w)
PyFPE_START_PROTECT("complex_div", return 0)
c_error = 0;
quot = c_quot(v->cval,w->cval);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(quot)
if (c_error == 1) {
err_setstr(ZeroDivisionError, "complex division");
return NULL;
@ -480,7 +480,7 @@ complex_pow(v, w, z)
else
p = c_pow(v->cval,exponent);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(p)
if (c_error == 2) {
err_setstr(ValueError, "0.0 to a negative or complex power");
return NULL;
@ -514,7 +514,7 @@ complex_abs(v)
double result;
PyFPE_START_PROTECT("complex_abs", return 0)
result = hypot(v->cval.real,v->cval.imag);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(result)
return newfloatobject(result);
}

View File

@ -260,7 +260,7 @@ float_add(v, w)
double result;
PyFPE_START_PROTECT("add", return 0)
result = v->ob_fval + w->ob_fval;
PyFPE_END_PROTECT
PyFPE_END_PROTECT(result)
return newfloatobject(result);
}
@ -272,7 +272,7 @@ float_sub(v, w)
double result;
PyFPE_START_PROTECT("subtract", return 0)
result = v->ob_fval - w->ob_fval;
PyFPE_END_PROTECT
PyFPE_END_PROTECT(result)
return newfloatobject(result);
}
@ -285,7 +285,7 @@ float_mul(v, w)
PyFPE_START_PROTECT("multiply", return 0)
result = v->ob_fval * w->ob_fval;
PyFPE_END_PROTECT
PyFPE_END_PROTECT(result)
return newfloatobject(result);
}
@ -301,7 +301,7 @@ float_div(v, w)
}
PyFPE_START_PROTECT("divide", return 0)
result = v->ob_fval / w->ob_fval;
PyFPE_END_PROTECT
PyFPE_END_PROTECT(result)
return newfloatobject(result);
}
@ -325,7 +325,7 @@ float_rem(v, w)
mod += wx;
/* div -= 1.0; */
}
PyFPE_END_PROTECT
PyFPE_END_PROTECT(mod)
return newfloatobject(mod);
}
@ -349,7 +349,7 @@ float_divmod(v, w)
mod += wx;
div -= 1.0;
}
PyFPE_END_PROTECT
PyFPE_END_PROTECT(div)
return mkvalue("(dd)", div, mod);
}
@ -394,7 +394,7 @@ float_pow(v, w, z)
if (ix!=0 && z->ob_fval<0) ix+=z->ob_fval;
}
else ix=1.0;
PyFPE_END_PROTECT
PyFPE_END_PROTECT(ix)
return newfloatobject(ix);
}
errno = 0;
@ -403,7 +403,7 @@ float_pow(v, w, z)
ix = powu(iv, intw);
else
ix = 1./powu(iv, -intw);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(ix)
}
else {
/* Sort out special cases here instead of relying on pow() */
@ -423,7 +423,7 @@ float_pow(v, w, z)
errno = 0;
PyFPE_START_PROTECT("pow", return 0)
ix = pow(iv, iw);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(ix)
}
CHECK(ix);
if (errno != 0) {
@ -438,7 +438,7 @@ float_pow(v, w, z)
((iv<0 && z->ob_fval>0) || (iv>0 && z->ob_fval<0) )) {
ix+=z->ob_fval;
}
PyFPE_END_PROTECT
PyFPE_END_PROTECT(ix)
}
return newfloatobject(ix);
}

View File

@ -1421,7 +1421,7 @@ long_float(v)
double result;
PyFPE_START_PROTECT("long_float", return 0)
result = dgetlongvalue(v);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(result)
return newfloatobject(result);
}

View File

@ -818,14 +818,14 @@ parsenumber(co, s)
c.real = 0.;
PyFPE_START_PROTECT("atof", return 0)
c.imag = atof(s);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(c)
return newcomplexobject(c);
}
else {
#endif
PyFPE_START_PROTECT("atof", return 0)
dx = atof(s);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(dx)
return newfloatobject(dx);
}
}

View File

@ -422,7 +422,7 @@ r_object(p)
buf[n] = '\0';
PyFPE_START_PROTECT("atof", return 0)
dx = atof(buf);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(dx)
return newfloatobject(dx);
}
@ -441,7 +441,7 @@ r_object(p)
buf[n] = '\0';
PyFPE_START_PROTECT("atof", return 0)
c.real = atof(buf);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(c)
n = r_byte(p);
if (r_string(buf, (int)n, p) != n) {
err_setstr(EOFError,
@ -451,7 +451,7 @@ r_object(p)
buf[n] = '\0';
PyFPE_START_PROTECT("atof", return 0)
c.imag = atof(buf);
PyFPE_END_PROTECT
PyFPE_END_PROTECT(c)
return newcomplexobject(c);
}
#endif

View File

@ -12,5 +12,5 @@
#ifdef WANT_SIGFPE_HANDLER
jmp_buf PyFPE_jbuf;
int PyFPE_counter = 0;
double PyFPE_dummy(void){return(1.0);}
double PyFPE_dummy(){return(1.0);}
#endif