diff options
author | JustAnotherArchivist <JustAnotherArchivist@users.noreply.github.com> | 2022-07-28 22:12:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-28 22:12:27 (GMT) |
commit | 03da5d0f5b8c954d9b4d2ad837518dd605e60355 (patch) | |
tree | dae01fa6af3c47d4ea216eb5f6eaa00f46bde242 | |
parent | 26d4af0ba538ea58d7a7fdbcc4471d9b32689b28 (diff) | |
download | cpython-03da5d0f5b8c954d9b4d2ad837518dd605e60355.zip cpython-03da5d0f5b8c954d9b4d2ad837518dd605e60355.tar.gz cpython-03da5d0f5b8c954d9b4d2ad837518dd605e60355.tar.bz2 |
gh-59200: Clarify `PyLong_FromString` documentation (GH-94363)
-rw-r--r-- | Doc/c-api/long.rst | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index 620344e..56a7c06 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -84,14 +84,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate. .. c:function:: PyObject* PyLong_FromString(const char *str, char **pend, int base) Return a new :c:type:`PyLongObject` based on the string value in *str*, which - is interpreted according to the radix in *base*. If *pend* is non-``NULL``, - *\*pend* will point to the first character in *str* which follows the - representation of the number. If *base* is ``0``, *str* is interpreted using - the :ref:`integers` definition; in this case, leading zeros in a - non-zero decimal number raises a :exc:`ValueError`. If *base* is not ``0``, - it must be between ``2`` and ``36``, inclusive. Leading spaces and single - underscores after a base specifier and between digits are ignored. If there - are no digits, :exc:`ValueError` will be raised. + is interpreted according to the radix in *base*, or ``NULL`` on failure. If + *pend* is non-``NULL``, *\*pend* will point to the end of *str* on success or + to the first character that could not be processed on error. If *base* is ``0``, + *str* is interpreted using the :ref:`integers` definition; in this case, leading + zeros in a non-zero decimal number raises a :exc:`ValueError`. If *base* is not + ``0``, it must be between ``2`` and ``36``, inclusive. Leading and trailing + whitespace and single underscores after a base specifier and between digits are + ignored. If there are no digits or *str* is not NULL-terminated following the + digits and trailing whitespace, :exc:`ValueError` will be raised. .. c:function:: PyObject* PyLong_FromUnicodeObject(PyObject *u, int base) |