[Python-checkins] cpython (merge 3.5 -> 3.6): 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/2ae3f1599c34
changeset:   104846:2ae3f1599c34
branch:      3.6
parent:      104843:fb64c7a81010
parent:      104845:32d8c89e90d1
user:        INADA Naoki <songofacandy at gmail.com>
date:        Mon Oct 31 17:42:10 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