aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorMathieu Bridon <[email protected]>2018-08-09 10:27:22 +0200
committerDylan Baker <[email protected]>2018-08-09 16:49:19 -0700
commit1e668ca111563b122b16be5506638983b31205b5 (patch)
tree0654f232c600cae9278cdf77437c7fceed94559e /src/gallium/auxiliary/util
parent14f1ab998fcdcd8fec43c3da8ef03af4af2d3966 (diff)
python: Better check for integer types
Python 3 lost the long type: now everything is an int, with the right size. This commit makes the script compatible with Python 2 (where we check for both int and long) and Python 3 (where we only check for int). Signed-off-by: Mathieu Bridon <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_format_pack.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index ad2e49281fb..c1307d30c2f 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -38,9 +38,18 @@
from __future__ import division, print_function
+import sys
+
from u_format_parse import *
+if sys.version_info < (3, 0):
+ integer_types = (int, long)
+
+else:
+ integer_types = (int, )
+
+
def inv_swizzles(swizzles):
'''Return an array[4] of inverse swizzle terms'''
'''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha'''
@@ -212,7 +221,7 @@ def truncate_mantissa(x, bits):
'''Truncate an integer so it can be represented exactly with a floating
point mantissa'''
- assert isinstance(x, (int, long))
+ assert isinstance(x, integer_types)
s = 1
if x < 0:
@@ -236,7 +245,7 @@ def value_to_native(type, value):
'''Get the value of unity for this type.'''
if type.type == FLOAT:
if type.size <= 32 \
- and isinstance(value, (int, long)):
+ and isinstance(value, integer_types):
return truncate_mantissa(value, 23)
return value
if type.type == FIXED: