[Python-checkins] python/dist/src/Objects stringobject.c,2.172,2.173
nnorwitz@users.sourceforge.net
nnorwitz@users.sourceforge.net
Sun, 28 Jul 2002 09:44:25 -0700
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv6096/Objects
Modified Files:
stringobject.c
Log Message:
Fix the problem of not raising a TypeError exception when doing:
'%g' % '1'
'%d' % '1'
Add a test for these conditions
Fix the test so that if not exception is raise, this is a failure
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.172
retrieving revision 2.173
diff -C2 -d -r2.172 -r2.173
*** stringobject.c 28 Jul 2002 15:19:47 -0000 2.172
--- stringobject.c 28 Jul 2002 16:44:23 -0000 2.173
***************
*** 3121,3129 ****
char fmt[20];
double x;
! v = PyNumber_Float(v);
! if (!v)
return -1;
! x = PyFloat_AS_DOUBLE(v);
! Py_DECREF(v);
if (prec < 0)
prec = 6;
--- 3121,3129 ----
char fmt[20];
double x;
! x = PyFloat_AsDouble(v);
! if (x == -1.0 && PyErr_Occurred()) {
! PyErr_SetString(PyExc_TypeError, "float argument required");
return -1;
! }
if (prec < 0)
prec = 6;
***************
*** 3300,3308 ****
long x;
! v = PyNumber_Int(v);
! if (!v)
return -1;
! x = PyInt_AS_LONG(v);
! Py_DECREF(v);
if (prec < 0)
prec = 1;
--- 3300,3308 ----
long x;
! x = PyInt_AsLong(v);
! if (x == -1 && PyErr_Occurred()) {
! PyErr_SetString(PyExc_TypeError, "int argument required");
return -1;
! }
if (prec < 0)
prec = 1;