[Python-checkins] cpython (3.5): Issue #28553: Fix logic error in example code of int.to_bytes doc.
inada.naoki
python-checkins at python.org
Mon Oct 31 04:42:40 EDT 2016
https://hg.python.org/cpython/rev/32d8c89e90d1
changeset: 104845:32d8c89e90d1
branch: 3.5
parent: 104842:b06f15507978
user: INADA Naoki <songofacandy at gmail.com>
date: Mon Oct 31 17:41:47 2016 +0900
summary:
Issue #28553: Fix logic error in example code of int.to_bytes doc.
files:
Doc/library/stdtypes.rst | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -485,7 +485,7 @@
>>> (-1024).to_bytes(10, byteorder='big', signed=True)
b'\xff\xff\xff\xff\xff\xff\xff\xff\xfc\x00'
>>> x = 1000
- >>> x.to_bytes((x.bit_length() // 8) + 1, byteorder='little')
+ >>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
b'\xe8\x03'
The integer is represented using *length* bytes. An :exc:`OverflowError`
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list