[Python-checkins] python/dist/src/Include pyport.h,2.66,2.67
perky at users.sourceforge.net
perky at users.sourceforge.net
Mon Mar 22 03:43:57 EST 2004
Update of /cvsroot/python/python/dist/src/Include
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19398/Include
Modified Files:
pyport.h
Log Message:
Patch #871657: Set EDOM for `nan' return values on FreeBSD and OpenBSD.
This fixes a problem that math.sqrt(-1) doesn't raise math.error.
Index: pyport.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v
retrieving revision 2.66
retrieving revision 2.67
diff -C2 -d -r2.66 -r2.67
*** pyport.h 10 Feb 2004 16:50:18 -0000 2.66
--- pyport.h 22 Mar 2004 08:43:55 -0000 2.67
***************
*** 274,292 ****
#endif
! /* Py_SET_ERANGE_ON_OVERFLOW(x)
* If a libm function did not set errno, but it looks like the result
! * overflowed, set errno to ERANGE. Set errno to 0 before calling a libm
! * function, and invoke this macro after, passing the function result.
* Caution:
* This isn't reliable. See Py_OVERFLOWED comments.
* X is evaluated more than once.
*/
! #define Py_SET_ERANGE_IF_OVERFLOW(X) \
do { \
! if (errno == 0 && ((X) == Py_HUGE_VAL || \
! (X) == -Py_HUGE_VAL)) \
! errno = ERANGE; \
} while(0)
/* Py_ADJUST_ERANGE1(x)
* Py_ADJUST_ERANGE2(x, y)
--- 274,305 ----
#endif
! /* Py_SET_ERRNO_ON_MATH_ERROR(x)
* If a libm function did not set errno, but it looks like the result
! * overflowed or not-a-number, set errno to ERANGE or EDOM. Set errno
! * to 0 before calling a libm function, and invoke this macro after,
! * passing the function result.
* Caution:
* This isn't reliable. See Py_OVERFLOWED comments.
* X is evaluated more than once.
*/
! #if defined(__FreeBSD__) || defined(__OpenBSD__)
! #define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM;
! #else
! #define _Py_SET_EDOM_FOR_NAN(X) ;
! #endif
! #define Py_SET_ERRNO_ON_MATH_ERROR(X) \
do { \
! if (errno == 0) { \
! if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \
! errno = ERANGE; \
! else _Py_SET_EDOM_FOR_NAN(X) \
! } \
} while(0)
+ /* Py_SET_ERANGE_ON_OVERFLOW(x)
+ * An alias of Py_SET_ERRNO_ON_MATH_ERROR for backward-compatibility.
+ */
+ #define Py_SET_ERANGE_IF_OVERFLOW(X) Py_SET_ERRNO_ON_MATH_ERROR(X)
+
/* Py_ADJUST_ERANGE1(x)
* Py_ADJUST_ERANGE2(x, y)
More information about the Python-checkins
mailing list