[Python-checkins] CVS: python/dist/src/Objects floatobject.c,2.109,2.110
Tim Peters
tim_one@users.sourceforge.net
Tue, 11 Dec 2001 12:31:37 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv1187/python/objects
Modified Files:
floatobject.c
Log Message:
float_floor_div: An expression like 3.//1j crashed the interpreter, or
delivered bizarre results. Check float_divmod for a Py_NotImplemented
return and pass it along (instead of treating Py_NotImplemented as a
2-tuple).
CONVERT_TO_DOUBLE: Added comments; this macro is obscure.
Index: floatobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v
retrieving revision 2.109
retrieving revision 2.110
diff -C2 -d -r2.109 -r2.110
*** floatobject.c 2001/12/11 19:57:24 2.109
--- floatobject.c 2001/12/11 20:31:34 2.110
***************
*** 266,271 ****
/* Macro and helper that convert PyObject obj to a C double and store
the value in dbl; this replaces the functionality of the coercion
! slot function */
!
#define CONVERT_TO_DOUBLE(obj, dbl) \
if (PyFloat_Check(obj)) \
--- 266,274 ----
/* Macro and helper that convert PyObject obj to a C double and store
the value in dbl; this replaces the functionality of the coercion
! slot function. If conversion to double raises an exception, obj is
! set to NULL, and the function invoking this macro returns NULL. If
! obj is not of float, int or long type, Py_NotImplemented is incref'ed,
! stored in obj, and returned from the function invoking this macro.
! */
#define CONVERT_TO_DOUBLE(obj, dbl) \
if (PyFloat_Check(obj)) \
***************
*** 520,530 ****
t = float_divmod(v, w);
! if (t != NULL) {
! r = PyTuple_GET_ITEM(t, 0);
! Py_INCREF(r);
! Py_DECREF(t);
! return r;
! }
! return NULL;
}
--- 523,533 ----
t = float_divmod(v, w);
! if (t == NULL || t == Py_NotImplemented)
! return t;
! assert(PyTuple_CheckExact(t));
! r = PyTuple_GET_ITEM(t, 0);
! Py_INCREF(r);
! Py_DECREF(t);
! return r;
}