mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
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:
parent
66edb6295f
commit
3a313e3655
5 changed files with 138 additions and 41 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue