Skip to content

Commit 03da5d0

Browse files
gh-59200: Clarify PyLong_FromString documentation (GH-94363)
1 parent 26d4af0 commit 03da5d0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Doc/c-api/long.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,15 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
8484
.. c:function:: PyObject* PyLong_FromString(const char *str, char **pend, int base)
8585
8686
Return a new :c:type:`PyLongObject` based on the string value in *str*, which
87-
is interpreted according to the radix in *base*. If *pend* is non-``NULL``,
88-
*\*pend* will point to the first character in *str* which follows the
89-
representation of the number. If *base* is ``0``, *str* is interpreted using
90-
the :ref:`integers` definition; in this case, leading zeros in a
91-
non-zero decimal number raises a :exc:`ValueError`. If *base* is not ``0``,
92-
it must be between ``2`` and ``36``, inclusive. Leading spaces and single
93-
underscores after a base specifier and between digits are ignored. If there
94-
are no digits, :exc:`ValueError` will be raised.
87+
is interpreted according to the radix in *base*, or ``NULL`` on failure. If
88+
*pend* is non-``NULL``, *\*pend* will point to the end of *str* on success or
89+
to the first character that could not be processed on error. If *base* is ``0``,
90+
*str* is interpreted using the :ref:`integers` definition; in this case, leading
91+
zeros in a non-zero decimal number raises a :exc:`ValueError`. If *base* is not
92+
``0``, it must be between ``2`` and ``36``, inclusive. Leading and trailing
93+
whitespace and single underscores after a base specifier and between digits are
94+
ignored. If there are no digits or *str* is not NULL-terminated following the
95+
digits and trailing whitespace, :exc:`ValueError` will be raised.
9596
9697
9798
.. c:function:: PyObject* PyLong_FromUnicodeObject(PyObject *u, int base)

0 commit comments

Comments
 (0)