Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b8dc3ab0
Commit
b8dc3ab0
authored
Jun 23, 2012
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #12965: More PyLong_As* clarifications. Thanks Stefan Krah.
parent
f0acfeec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
22 deletions
+39
-22
Doc/c-api/long.rst
Doc/c-api/long.rst
+39
-22
No files found.
Doc/c-api/long.rst
View file @
b8dc3ab0
...
...
@@ -167,9 +167,11 @@ All integers are implemented as "long" integer objects of arbitrary size.
single: PY_SSIZE_T_MAX
single: OverflowError (built-in exception)
Return a C :c:type:`Py_ssize_t` representation of the contents of *pylong*.
If *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError`
is raised and ``-1`` will be returned.
Return a C :c:type:`Py_ssize_t` representation of *pylong*. *pylong* must
be an instance of :c:type:`PyLongObject`.
Raise :exc:`OverflowError` if the value of *pylong* is out of range for a
:c:type:`Py_ssize_t`.
.. c:function:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong)
...
...
@@ -178,16 +180,20 @@ All integers are implemented as "long" integer objects of arbitrary size.
single: ULONG_MAX
single: OverflowError (built-in exception)
Return a C :c:type:`unsigned long` representation of the contents of *pylong*.
If *pylong* is greater than :const:`ULONG_MAX`, an :exc:`OverflowError` is
raised.
Return a C :c:type:`unsigned long` representation of *pylong*. *pylong*
must be an instance of :c:type:`PyLongObject`.
Raise :exc:`OverflowError` if the value of *pylong* is out of range for a
:c:type:`unsigned long`.
.. c:function:: size_t PyLong_AsSize_t(PyObject *pylong)
Return a :c:type:`size_t` representation of the contents of *pylong*. If
*pylong* is greater than the maximum value for a :c:type:`size_t`, an
:exc:`OverflowError` is raised.
Return a C :c:type:`size_t` representation of of *pylong*. *pylong* must be
an instance of :c:type:`PyLongObject`.
Raise :exc:`OverflowError` if the value of *pylong* is out of range for a
:c:type:`size_t`.
.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong)
...
...
@@ -195,32 +201,43 @@ All integers are implemented as "long" integer objects of arbitrary size.
.. index::
single: OverflowError (built-in exception)
Return a C :c:type:`unsigned long long` from a Python integer. If
*pylong* cannot be represented as an :c:type:`unsigned long long`,
an :exc:`OverflowError` is raised and ``(unsigned long long)-1`` is
returned.
Return a C :c:type:`unsigned PY_LONG_LONG` representation of of *pylong*.
*pylong* must be an instance of :c:type:`PyLongObject`.
Raise :exc:`OverflowError` if the value of *pylong* is out of range for an
:c:type:`unsigned PY_LONG_LONG`.
.. versionchanged:: 3.1
A negative *pylong* now raises :exc:`OverflowError`, not :exc:`TypeError`.
.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *
io
)
.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *
obj
)
Return a C :c:type:`unsigned long` from a Python integer, without checking for
overflow.
Return a C :c:type:`unsigned long` representation of *obj*. If *obj*
is not an instance of :c:type:`PyLongObject`, first call its :meth:`__int__`
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 :const:`ULONG_MAX + 1`.
.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io)
Return a C :c:type:`unsigned long long` from a Python integer, without
checking for overflow.
.. c:function:: unsigned PY_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:`__int__`
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 :const:`PY_ULLONG_MAX + 1`.
.. c:function:: double PyLong_AsDouble(PyObject *pylong)
Return a C :c:type:`double` representation of the contents of *pylong*. If
*pylong* cannot be approximately represented as a :c:type:`double`, an
:exc:`OverflowError` exception is raised and ``-1.0`` will be returned.
Return a C :c:type:`double` representation of *pylong*. *pylong* must be
an instance of :c:type:`PyLongObject`.
Raise :exc:`OverflowError` if the value of *pylong* is out of range for a
:c:type:`double`.
.. c:function:: void* PyLong_AsVoidPtr(PyObject *pylong)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment