Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Also update C-API documentation
  • Loading branch information
mdickinson committed May 27, 2020
commit ad59ccd60ffa80c011f619982f05c1746dc81adf
49 changes: 31 additions & 18 deletions Doc/c-api/long.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
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`.
Expand All @@ -144,13 +143,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. deprecated:: 3.8
Using :meth:`__int__` is deprecated.

.. versionchanged:: 3.10
This function will no longer use :meth:`__int__`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually also remove corresponding deprecated directives when the deprecated feature has been removed. So I suggest to remove deprecated few lines above.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!



.. 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__`
(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
Expand All @@ -165,16 +166,18 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. 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)

.. index::
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`.
Expand All @@ -187,13 +190,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. 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__` (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,
Expand All @@ -210,6 +215,9 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. 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)

Expand Down Expand Up @@ -278,10 +286,9 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.

.. 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``.
Expand All @@ -295,13 +302,16 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. 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``.
Expand All @@ -315,6 +325,9 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. 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)

Expand Down