diff options
Diffstat (limited to 'Doc/c-api')
-rw-r--r-- | Doc/c-api/long.rst | 19 | ||||
-rw-r--r-- | Doc/c-api/number.rst | 11 |
2 files changed, 26 insertions, 4 deletions
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index d83a8fe..b0debe3 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -52,14 +52,14 @@ All integers are implemented as "long" integer objects of arbitrary size. .. cfunction:: PyObject* PyLong_FromSsize_t(Py_ssize_t v) - Return a new :ctype:`PyLongObject` object with a value of *v*, or *NULL* - on failure. + Return a new :ctype:`PyLongObject` object from a C :ctype:`Py_ssize_t`, or + *NULL* on failure. .. cfunction:: PyObject* PyLong_FromSize_t(size_t v) - Return a new :ctype:`PyLongObject` object with a value of *v*, or *NULL* - on failure. + Return a new :ctype:`PyLongObject` object from a C :ctype:`size_t`, or + *NULL* on failure. .. cfunction:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v) @@ -127,6 +127,17 @@ All integers are implemented as "long" integer objects of arbitrary size. If an exception is set because of type errors, also return -1. +.. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong) + + .. index:: + single: PY_SSIZE_T_MAX + single: OverflowError (built-in exception) + + Return a C :ctype:`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. + + .. cfunction:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong) .. index:: diff --git a/Doc/c-api/number.rst b/Doc/c-api/number.rst index 6c73bfa..187fe73 100644 --- a/Doc/c-api/number.rst +++ b/Doc/c-api/number.rst @@ -259,6 +259,17 @@ Number Protocol TypeError exception raised on failure. +.. cfunction:: PyObject* PyNumber_ToBase(PyObject *n, int base) + + Returns the the integer *n* converted to *base* as a string with a base + marker of ``'0b'``, ``'0o'``, or ``'0x'`` if appended applicable. When + *base* is not 2, 8, 10, or 16, the format is ``'x#num'`` where x is the + base. If *n* is not an int object, it is converted with + :cfunc:`PyNumber_Index` first. + + .. versionadded:: 2.6 + + .. cfunction:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc) Returns *o* converted to a Py_ssize_t value if *o* can be interpreted as an |