diff mbox

[U-Boot,v2,10/10] dtoc: Make integer division python 3.x safe

Message ID 20160927150358.6248-11-paul.burton@imgtec.com
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Paul Burton Sept. 27, 2016, 3:03 p.m. UTC
If we use the '/' operator then python 3.x will produce a float, and
refuse to multiply the string sequence in Conv_name_to_c by it with:

    TypeError: can't multiply sequence by non-int of type 'float'

Use the '//' operator instead to enforce that we want integer rather
than floating point division.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Acked-by: Simon Glass <sjg@chromium.org>

---

Changes in v2: None

 tools/dtoc/dtoc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass Oct. 6, 2016, 2:03 a.m. UTC | #1
On 27 September 2016 at 09:03, Paul Burton <paul.burton@imgtec.com> wrote:
> If we use the '/' operator then python 3.x will produce a float, and
> refuse to multiply the string sequence in Conv_name_to_c by it with:
>
>     TypeError: can't multiply sequence by non-int of type 'float'
>
> Use the '//' operator instead to enforce that we want integer rather
> than floating point division.
>
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> Acked-by: Simon Glass <sjg@chromium.org>
>
> ---
>
> Changes in v2: None
>
>  tools/dtoc/dtoc.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm, thanks!
diff mbox

Patch

diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py
index 12aa990..11050b6 100755
--- a/tools/dtoc/dtoc.py
+++ b/tools/dtoc/dtoc.py
@@ -60,7 +60,7 @@  def Conv_name_to_c(name):
 def TabTo(num_tabs, str):
     if len(str) >= num_tabs * 8:
         return str + ' '
-    return str + '\t' * (num_tabs - len(str) / 8)
+    return str + '\t' * (num_tabs - len(str) // 8)
 
 class DtbPlatdata:
     """Provide a means to convert device tree binary data to platform data