Check the type of values returned by __int__, __float__, __long__,

__oct__, and __hex__.  Raise TypeError if an invalid type is
returned.  Note that PyNumber_Int and PyNumber_Long can still
return ints or longs.  Fixes SF bug #966618.
This commit is contained in:
Neil Schemenauer 2004-07-19 16:29:17 +00:00
parent 66edb6295f
commit 3a313e3655
5 changed files with 138 additions and 41 deletions

View file

@ -948,12 +948,6 @@ int_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (tmp == NULL)
return NULL;
if (!PyInt_Check(tmp)) {
if (!PyLong_Check(tmp)) {
PyErr_SetString(PyExc_ValueError,
"value can't be converted to int");
Py_DECREF(tmp);
return NULL;
}
ival = PyLong_AsLong(tmp);
if (ival == -1 && PyErr_Occurred()) {
Py_DECREF(tmp);