From 3e3e9f3667bd542ab75e38816c57eaeb12946aff Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Mon, 31 Oct 2016 17:41:47 +0900 Subject: [PATCH] Issue #28553: Fix logic error in example code of int.to_bytes doc. --- Doc/library/stdtypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 2587ac85b0b..5936c684591 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -485,7 +485,7 @@ class`. In addition, it provides a few more methods: >>> (-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`