From 9b6746b7c0bef64be419c8cf2ecd916980e2718a Mon Sep 17 00:00:00 2001 From: Mathieu Bridon Date: Wed, 25 Jul 2018 11:53:54 +0200 Subject: python: Use explicit integer divisions In Python 2, divisions of integers return an integer: >>> 32 / 4 8 In Python 3 though, they return floats: >>> 32 / 4 8.0 However, Python 3 has an explicit integer division operator: >>> 32 // 4 8 That operator exists on Python >= 2.2, so let's use it everywhere to make the scripts compatible with both Python 2 and 3. In addition, using __future__.division tells Python 2 to behave the same way as Python 3, which helps ensure the scripts produce the same output in both versions of Python. Signed-off-by: Mathieu Bridon Reviewed-by: Eric Engestrom (v2) Reviewed-by: Dylan Baker --- src/mapi/glapi/gen/glX_proto_send.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mapi') diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py index a920ecc012f..03067d8a3cd 100644 --- a/src/mapi/glapi/gen/glX_proto_send.py +++ b/src/mapi/glapi/gen/glX_proto_send.py @@ -26,7 +26,7 @@ # Ian Romanick # Jeremy Kolb -from __future__ import print_function +from __future__ import division, print_function import argparse @@ -809,7 +809,7 @@ generic_%u_byte( GLint rop, const void * ptr ) # Dividing by the array size (1 for # non-arrays) gives us this. - s = p.size() / p.get_element_count() + s = p.size() // p.get_element_count() print(" %s __glXReadReply(dpy, %s, %s, %s);" % (return_str, s, p.name, aa)) got_reply = 1 -- cgit v1.2.3