Make int() and long() fall back to __trunc__(). See issue 2002.

This commit is contained in:
Jeffrey Yasskin 2008-02-04 01:04:35 +00:00
parent 72a6576279
commit a26cf9b760
5 changed files with 232 additions and 3 deletions

View file

@ -760,6 +760,19 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc);
/*
Returns the Integral instance converted to an int. The
instance is expected to be int or long or have an __int__
method. Steals integral's reference. error_format will be
used to create the TypeError if integral isn't actually an
Integral instance. error_format should be a format string
that can accept a char* naming integral's type.
*/
PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt(
PyObject *integral,
const char* error_format);
/*
Returns the object converted to Py_ssize_t by going through
PyNumber_Index first. If an overflow error occurs while