single: OverflowError (built-in exception)
Return a C :c:type:`long` representation of *obj*. If *obj* is not an
- instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
- :meth:`__int__` method (if present) to convert it to a
- :c:type:`PyLongObject`.
+ instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
+ (if present) to convert it to a :c:type:`PyLongObject`.
Raise :exc:`OverflowError` if the value of *obj* is out of range for a
:c:type:`long`.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
- .. deprecated:: 3.8
- Using :meth:`__int__` is deprecated.
+ .. versionchanged:: 3.10
+ This function will no longer use :meth:`__int__`.
.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
Return a C :c:type:`long` representation of *obj*. If *obj* is not an
- instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
- :meth:`__int__` method (if present) to convert it to a
- :c:type:`PyLongObject`.
+ instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
+ method (if present) to convert it to a :c:type:`PyLongObject`.
If the value of *obj* is greater than :const:`LONG_MAX` or less than
:const:`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively, and
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
- .. deprecated:: 3.8
- Using :meth:`__int__` is deprecated.
+ .. versionchanged:: 3.10
+ This function will no longer use :meth:`__int__`.
.. c:function:: long long PyLong_AsLongLong(PyObject *obj)
single: OverflowError (built-in exception)
Return a C :c:type:`long long` representation of *obj*. If *obj* is not an
- instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
- :meth:`__int__` method (if present) to convert it to a
- :c:type:`PyLongObject`.
+ instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
+ (if present) to convert it to a :c:type:`PyLongObject`.
Raise :exc:`OverflowError` if the value of *obj* is out of range for a
:c:type:`long long`.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
- .. deprecated:: 3.8
- Using :meth:`__int__` is deprecated.
+ .. versionchanged:: 3.10
+ This function will no longer use :meth:`__int__`.
.. c:function:: long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
Return a C :c:type:`long long` representation of *obj*. If *obj* is not an
- instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
- :meth:`__int__` method (if present) to convert it to a
- :c:type:`PyLongObject`.
+ instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
+ (if present) to convert it to a :c:type:`PyLongObject`.
If the value of *obj* is greater than :const:`LLONG_MAX` or less than
:const:`LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively,
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
- .. deprecated:: 3.8
- Using :meth:`__int__` is deprecated.
+ .. versionchanged:: 3.10
+ This function will no longer use :meth:`__int__`.
.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj)
- Return a C :c:type:`unsigned long` representation of *obj*. If *obj*
- is not an instance of :c:type:`PyLongObject`, first call its
- :meth:`__index__` or :meth:`__int__` method (if present) to convert
- it to a :c:type:`PyLongObject`.
+ Return a C :c:type:`unsigned long` representation of *obj*. If *obj* is not
+ an instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
+ method (if present) to convert it to a :c:type:`PyLongObject`.
If the value of *obj* is out of range for an :c:type:`unsigned long`,
return the reduction of that value modulo ``ULONG_MAX + 1``.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
- .. deprecated:: 3.8
- Using :meth:`__int__` is deprecated.
+ .. versionchanged:: 3.10
+ This function will no longer use :meth:`__int__`.
.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)
Return a C :c:type:`unsigned long long` representation of *obj*. If *obj*
is not an instance of :c:type:`PyLongObject`, first call its
- :meth:`__index__` or :meth:`__int__` method (if present) to convert
- it to a :c:type:`PyLongObject`.
+ :meth:`__index__` method (if present) to convert it to a
+ :c:type:`PyLongObject`.
If the value of *obj* is out of range for an :c:type:`unsigned long long`,
return the reduction of that value modulo ``ULLONG_MAX + 1``.
.. versionchanged:: 3.8
Use :meth:`__index__` if available.
- .. deprecated:: 3.8
- Using :meth:`__int__` is deprecated.
+ .. versionchanged:: 3.10
+ This function will no longer use :meth:`__int__`.
.. c:function:: double PyLong_AsDouble(PyObject *pylong)
#define PY_ABS_LONG_MIN (0-(unsigned long)LONG_MIN)
#define PY_ABS_SSIZE_T_MIN (0-(size_t)PY_SSIZE_T_MIN)
-/* Get a C long int from an int object or any object that has an __int__
+/* Get a C long int from an int object or any object that has an __index__
method.
On overflow, return -1 and set *overflow to 1 or -1 depending on the sign of
long res;
Py_ssize_t i;
int sign;
- int do_decref = 0; /* if nb_int was called */
+ int do_decref = 0; /* if PyNumber_Index was called */
*overflow = 0;
if (vv == NULL) {
return res;
}
-/* Get a C long int from an int object or any object that has an __int__
+/* Get a C long int from an int object or any object that has an __index__
method. Return -1 and set an error if overflow occurs. */
long
return result;
}
-/* Get a C int from an int object or any object that has an __int__
+/* Get a C int from an int object or any object that has an __index__
method. Return -1 and set an error if overflow occurs. */
int
}
/* Get a C long long int from an int object or any object that has an
- __int__ method. Return -1 and set an error if overflow occurs. */
+ __index__ method. Return -1 and set an error if overflow occurs. */
long long
PyLong_AsLongLong(PyObject *vv)
PyLongObject *v;
long long bytes;
int res;
- int do_decref = 0; /* if nb_int was called */
+ int do_decref = 0; /* if PyNumber_Index was called */
if (vv == NULL) {
PyErr_BadInternalCall();
}
/* Get a C long long int from an int object or any object that has an
- __int__ method.
+ __index__ method.
On overflow, return -1 and set *overflow to 1 or -1 depending on the sign of
the result. Otherwise *overflow is 0.
long long res;
Py_ssize_t i;
int sign;
- int do_decref = 0; /* if nb_int was called */
+ int do_decref = 0; /* if PyNumber_Index was called */
*overflow = 0;
if (vv == NULL) {