[Python-checkins] python/dist/src/Objects longobject.c,1.165,1.166
loewis at users.sourceforge.net
loewis at users.sourceforge.net
Thu Mar 3 13:26:37 CET 2005
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27103/Objects
Modified Files:
longobject.c
Log Message:
Revert previous checkin on getargs 'L' code. Try to convert all
numbers in PyLong_AsLongLong, and update test suite accordingly.
Backported to 2.4.
Index: longobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -d -r1.165 -r1.166
--- longobject.c 20 Sep 2004 06:14:54 -0000 1.165
+++ longobject.c 3 Mar 2005 12:26:34 -0000 1.166
@@ -783,9 +783,30 @@
return -1;
}
if (!PyLong_Check(vv)) {
+ PyNumberMethods *nb;
+ PyObject *io;
if (PyInt_Check(vv))
return (PY_LONG_LONG)PyInt_AsLong(vv);
- PyErr_BadInternalCall();
+ if ((nb = vv->ob_type->tp_as_number) == NULL ||
+ nb->nb_int == NULL) {
+ PyErr_SetString(PyExc_TypeError, "an integer is required");
+ return -1;
+ }
+ io = (*nb->nb_int) (vv);
+ if (io == NULL)
+ return -1;
+ if (PyInt_Check(io)) {
+ bytes = PyInt_AsLong(io);
+ Py_DECREF(io);
+ return bytes;
+ }
+ if (PyLong_Check(io)) {
+ bytes = PyLong_AsLongLong(io);
+ Py_DECREF(io);
+ return bytes;
+ }
+ Py_DECREF(io);
+ PyErr_SetString(PyExc_TypeError, "integer conversion failed");
return -1;
}
More information about the Python-checkins
mailing list