Skip to content

Commit 26896f2

Browse files
csabellaMariatta
authored andcommitted
bpo-29751: Improve PyLong_FromString documentation (GH-915)
1 parent 85157cd commit 26896f2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Doc/c-api/long.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,12 @@ All integers are implemented as "long" integer objects of arbitrary size.
8585
Return a new :c:type:`PyLongObject` based on the string value in *str*, which
8686
is interpreted according to the radix in *base*. If *pend* is non-*NULL*,
8787
*\*pend* will point to the first character in *str* which follows the
88-
representation of the number. If *base* is ``0``, the radix will be
89-
determined based on the leading characters of *str*: if *str* starts with
90-
``'0x'`` or ``'0X'``, radix 16 will be used; if *str* starts with ``'0o'`` or
91-
``'0O'``, radix 8 will be used; if *str* starts with ``'0b'`` or ``'0B'``,
92-
radix 2 will be used; otherwise radix 10 will be used. If *base* is not
93-
``0``, it must be between ``2`` and ``36``, inclusive. Leading spaces are
94-
ignored. If there are no digits, :exc:`ValueError` will be raised.
88+
representation of the number. If *base* is ``0``, *str* is interpreted using
89+
the :ref:`integers` definition; in this case, leading zeros in a
90+
non-zero decimal number raises a :exc:`ValueError`. If *base* is not ``0``,
91+
it must be between ``2`` and ``36``, inclusive. Leading spaces and single
92+
underscores after a base specifier and between digits are ignored. If there
93+
are no digits, :exc:`ValueError` will be raised.
9594
9695
9796
.. c:function:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)

0 commit comments

Comments
 (0)