diff options
author | Mariatta <Mariatta@users.noreply.github.com> | 2017-04-24 04:05:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-24 04:05:01 (GMT) |
commit | ea0efa3bc1d0b832da75519c6f85d767ae44feda (patch) | |
tree | dcd56be1c8a9c545c2d02a74f73de4879066fdf4 | |
parent | f2ed2858eea7569c8915b3611ca5ec92ae10b17f (diff) | |
download | cpython-ea0efa3bc1d0b832da75519c6f85d767ae44feda.zip cpython-ea0efa3bc1d0b832da75519c6f85d767ae44feda.tar.gz cpython-ea0efa3bc1d0b832da75519c6f85d767ae44feda.tar.bz2 |
[3.6] bpo-29751: Improve PyLong_FromString documentation (GH-915) (#1266)
(cherry picked from commit 26896f2832324dde85cdd63d525571ca669f6f0b)
-rw-r--r-- | Doc/c-api/long.rst | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst index f592cb6..f50680b 100644 --- a/Doc/c-api/long.rst +++ b/Doc/c-api/long.rst @@ -85,13 +85,12 @@ All integers are implemented as "long" integer objects of arbitrary size. 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``, the radix will be - determined based on the leading characters of *str*: if *str* starts with - ``'0x'`` or ``'0X'``, radix 16 will be used; if *str* starts with ``'0o'`` or - ``'0O'``, radix 8 will be used; if *str* starts with ``'0b'`` or ``'0B'``, - radix 2 will be used; otherwise radix 10 will be used. If *base* is not - ``0``, it must be between ``2`` and ``36``, inclusive. Leading spaces are - ignored. If there are no digits, :exc:`ValueError` will be raised. + 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. .. c:function:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base) |