python: drop python2 support
authorEric Engestrom <eric@engestrom.ch>
Sun, 2 Feb 2020 18:25:47 +0000 (18:25 +0000)
committerMarge Bot <eric+marge@anholt.net>
Sat, 14 Aug 2021 21:44:32 +0000 (21:44 +0000)
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3674>

63 files changed:
bin/install_megadrivers.py
bin/meson_get_version.py
src/amd/common/gfx10_format_table.py
src/amd/common/sid_tables.py
src/amd/registers/canonicalize.py
src/amd/registers/makeregheader.py
src/amd/registers/mergedbs.py
src/amd/registers/parseheader.py
src/amd/registers/regdb.py
src/broadcom/cle/gen_pack_header.py
src/compiler/glsl/glcpp/tests/glcpp_test.py
src/compiler/glsl/tests/lower_precision_test.py
src/compiler/glsl/tests/optimization_test.py
src/compiler/glsl/tests/sexps.py
src/compiler/glsl/tests/warnings_test.py
src/compiler/nir/nir_algebraic.py
src/compiler/nir/nir_builder_opcodes_h.py
src/compiler/nir/nir_constant_expressions.py
src/compiler/nir/nir_opcodes_c.py
src/compiler/nir/nir_opcodes_h.py
src/compiler/nir/nir_opt_algebraic.py
src/freedreno/ir3/ir3_nir_imul.py
src/freedreno/ir3/ir3_nir_trig.py
src/gallium/auxiliary/indices/u_indices_gen.py
src/gallium/auxiliary/indices/u_unfilled_gen.py
src/gallium/drivers/r600/egd_tables.py
src/gallium/drivers/swr/rasterizer/codegen/gen_archrast.py
src/gallium/drivers/swr/rasterizer/codegen/gen_backends.py
src/gallium/drivers/swr/rasterizer/codegen/gen_common.py
src/gallium/drivers/swr/rasterizer/codegen/gen_knobs.py
src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py
src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_types.py
src/intel/compiler/brw_nir_trig_workarounds.py
src/intel/genxml/gen_bits_header.py
src/intel/genxml/gen_pack_header.py
src/intel/genxml/gen_zipped_file.py
src/intel/isl/gen_format_layout.py
src/mapi/glapi/gen/glX_proto_common.py
src/mapi/glapi/gen/glX_proto_send.py
src/mapi/glapi/gen/glX_proto_size.py
src/mapi/glapi/gen/gl_SPARC_asm.py
src/mapi/glapi/gen/gl_XML.py
src/mapi/glapi/gen/gl_apitemp.py
src/mapi/glapi/gen/gl_enums.py
src/mapi/glapi/gen/gl_genexec.py
src/mapi/glapi/gen/gl_gentable.py
src/mapi/glapi/gen/gl_marshal.py
src/mapi/glapi/gen/gl_marshal_h.py
src/mapi/glapi/gen/gl_procs.py
src/mapi/glapi/gen/gl_table.py
src/mapi/glapi/gen/gl_x86-64_asm.py
src/mapi/glapi/gen/gl_x86_asm.py
src/mapi/glapi/gen/remap_helper.py
src/mapi/glapi/gen/typeexpr.py
src/mapi/mapi_abi.py
src/mesa/main/format_info.py
src/mesa/main/get_hash_generator.py
src/util/format/u_format_pack.py
src/util/format/u_format_parse.py
src/util/format/u_format_table.py
src/util/format_srgb.py
src/util/xxd.py
src/vulkan/util/gen_enum_to_str.py

index 0a28dd7..60ee457 100644 (file)
@@ -22,7 +22,6 @@
 
 """Script to install megadriver symlinks for meson."""
 
-from __future__ import print_function
 import argparse
 import os
 
index 2e631d2..9a44aa8 100644 (file)
@@ -20,7 +20,6 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-from __future__ import print_function
 import os
 
 
index 83c2119..9701499 100644 (file)
@@ -24,8 +24,6 @@
 Script that generates the mapping from Gallium PIPE_FORMAT_xxx to GFX10_FORMAT_xxx enums.
 """
 
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 import json
 import mako.template
 import os
index 6fc2ad0..c8fd312 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import print_function, division, unicode_literals
-
 CopyRight = '''
 /*
  * Copyright 2015-2019 Advanced Micro Devices, Inc.
index a1b7023..73c5452 100644 (file)
@@ -33,8 +33,6 @@ Notes about deduced register types as well as the output JSON are printed on
 stdout.
 """
 
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 from collections import defaultdict
 import json
 import re
index 770d678..3761884 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 COPYRIGHT = '''
 /*
  * Copyright 2015-2019 Advanced Micro Devices, Inc.
index 2a469e7..312aeb3 100644 (file)
@@ -28,8 +28,6 @@ Helper script to merge register database JSON files.
 Will merge the given JSON files and output the result on stdout.
 """
 
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 from collections import defaultdict
 import json
 import re
index d6602b7..9dd0543 100644 (file)
@@ -30,8 +30,6 @@ This script is included for reference -- we should be able to remove this in
 the future.
 """
 
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 import json
 import math
 import re
index 0167365..dab3e66 100644 (file)
@@ -24,8 +24,6 @@
 Python package containing common tools for manipulating register JSON.
 """
 
-from __future__ import absolute_import, division, print_function, unicode_literals
-
 import itertools
 import json
 import re
index cc9e4a0..0090b61 100644 (file)
@@ -22,9 +22,6 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-from __future__ import (
-    absolute_import, division, print_function, unicode_literals
-)
 import xml.parsers.expat
 import re
 import sys
index 0772770..b034754 100644 (file)
@@ -21,7 +21,6 @@
 
 """Run glcpp tests with various line endings."""
 
-from __future__ import print_function
 import argparse
 import difflib
 import errno
index 0ee67e0..51b0099 100644 (file)
@@ -19,7 +19,6 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-from __future__ import print_function
 import sys
 import subprocess
 import tempfile
index 0662728..7f5bdd6 100644 (file)
@@ -21,7 +21,6 @@
 
 """Script to generate and run glsl optimization tests."""
 
-from __future__ import print_function
 import argparse
 import difflib
 import errno
index 7de5db3..36fd725 100644 (file)
 
 import re
 import sys
-if sys.version_info >= (3, 0, 0):
-    STRING_TYPE = str
-else:
-    STRING_TYPE = unicode
 
 def check_sexp(sexp):
     """Verify that the argument is a proper sexp.
@@ -44,7 +40,7 @@ def check_sexp(sexp):
     if isinstance(sexp, list):
         for s in sexp:
             check_sexp(s)
-    elif not isinstance(sexp, (STRING_TYPE, bytes)):
+    elif not isinstance(sexp, (str, bytes)):
         raise Exception('Not a sexp: {0!r}'.format(sexp))
 
 def parse_sexp(sexp):
@@ -75,7 +71,7 @@ def sexp_to_string(sexp):
     """Convert a sexp, represented as nested lists containing strings,
     into a single string of the form parseable by mesa.
     """
-    if isinstance(sexp, STRING_TYPE):
+    if isinstance(sexp, str):
         return sexp
     if isinstance(sexp, bytes):
         return sexp.encode('utf-8')
index 61a1413..fed5a75 100644 (file)
@@ -19,7 +19,6 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-from __future__ import print_function
 import argparse
 import errno
 import os
index 37fefd8..2a4354a 100644 (file)
@@ -23,7 +23,6 @@
 # Authors:
 #    Jason Ekstrand (jason@jlekstrand.net)
 
-from __future__ import print_function
 import ast
 from collections import defaultdict
 import itertools
@@ -60,15 +59,6 @@ def get_c_opcode(op):
       else:
          return 'nir_op_' + op
 
-
-if sys.version_info < (3, 0):
-    integer_types = (int, long)
-    string_type = unicode
-
-else:
-    integer_types = (int, )
-    string_type = str
-
 _type_re = re.compile(r"(?P<type>int|uint|bool|float)?(?P<bits>\d+)?")
 
 def type_bits(type_str):
@@ -107,9 +97,9 @@ class Value(object):
          return Expression(val, name_base, varset)
       elif isinstance(val, Expression):
          return val
-      elif isinstance(val, string_type):
+      elif isinstance(val, str):
          return Variable(val, name_base, varset)
-      elif isinstance(val, (bool, float) + integer_types):
+      elif isinstance(val, (bool, float, int)):
          return Constant(val, name_base)
 
    def __init__(self, val, name, type_str):
@@ -246,7 +236,7 @@ class Constant(Value):
    def hex(self):
       if isinstance(self.value, (bool)):
          return 'NIR_TRUE' if self.value else 'NIR_FALSE'
-      if isinstance(self.value, integer_types):
+      if isinstance(self.value, int):
          return hex(self.value)
       elif isinstance(self.value, float):
          i = struct.unpack('Q', struct.pack('d', self.value))[0]
@@ -265,7 +255,7 @@ class Constant(Value):
    def type(self):
       if isinstance(self.value, (bool)):
          return "nir_type_bool"
-      elif isinstance(self.value, integer_types):
+      elif isinstance(self.value, int):
          return "nir_type_int"
       elif isinstance(self.value, float):
          return "nir_type_float"
index 006ed42..3e083ff 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
 template = """\
 /* Copyright (C) 2015 Broadcom
  *
index c1097de..3876b68 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
 import re
 from nir_opcodes import opcodes
 from nir_opcodes import type_has_size, type_size, type_sizes, type_base_type
index c6e5bb3..4f80d51 100644 (file)
@@ -23,8 +23,6 @@
 # Authors:
 #    Connor Abbott (cwabbott0@gmail.com)
 
-from __future__ import print_function
-
 from nir_opcodes import opcodes, type_sizes
 from mako.template import Template
 
index 6b4e2fe..1fc799b 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
 template = """\
 /* Copyright (C) 2014 Connor Abbott
  *
index fb6afb2..1582b1e 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Jason Ekstrand (jason@jlekstrand.net)
 
-from __future__ import print_function
-
 from collections import OrderedDict
 import nir_algebraic
 from nir_opcodes import type_sizes
index 45dee61..e6b6cbb 100644 (file)
@@ -20,8 +20,6 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-from __future__ import print_function
-
 import argparse
 import sys
 
index 93eb8ca..6a88420 100644 (file)
@@ -20,8 +20,6 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-from __future__ import print_function
-
 import argparse
 import sys
 
index 9a6fc06..71c0494 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
 copyright = '''
 /*
  * Copyright 2009 VMware, Inc.
index 4c7d7c6..0cb3f21 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
 copyright = '''
 /*
  * Copyright 2009 VMware, Inc.
index 8a60a62..010b0d7 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
 CopyRight = '''
 /*
  * Copyright 2015 Advanced Micro Devices, Inc.
index 140a39b..a4be675 100644 (file)
@@ -20,7 +20,6 @@
 # IN THE SOFTWARE.
 
 # Python source
-from __future__ import print_function
 import os
 import sys
 import re
index fa3e348..eb51a3a 100644 (file)
@@ -20,9 +20,7 @@
 # IN THE SOFTWARE.
 
 # Python source
-# Compatible with Python2.X and Python3.X
 
-from __future__ import print_function
 import itertools
 import os
 import sys
index cea3ac8..c1d08fb 100644 (file)
@@ -20,7 +20,6 @@
 # IN THE SOFTWARE.
 
 # Python source
-from __future__ import print_function
 import os
 import errno
 import sys
index 7733f86..bd39ef6 100644 (file)
@@ -20,7 +20,6 @@
 # IN THE SOFTWARE.
 
 # Python source
-from __future__ import print_function
 import os
 import sys
 import knob_defs
index 0b4f82c..f3ab712 100644 (file)
@@ -19,7 +19,6 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-from __future__ import print_function
 import os, sys, re
 from gen_common import *
 from argparse import FileType
index 7089a3d..4739f20 100644 (file)
@@ -19,7 +19,6 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-from __future__ import print_function
 import os, sys, re
 from gen_common import *
 from argparse import FileType
index dddadc7..7425ff4 100644 (file)
@@ -31,8 +31,6 @@
 # amplitude slightly.  Apparently this also minimizes the error function,
 # reducing the maximum error from 0.00006 to about 0.00003.
 
-from __future__ import print_function
-
 import argparse
 import sys
 
index 2b84eb2..1c1b244 100644 (file)
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-from __future__ import (
-    absolute_import, division, print_function, unicode_literals
-)
-
 import argparse
 import os
 import xml.parsers.expat
index 7472204..45bbb30 100644 (file)
@@ -1,8 +1,5 @@
 #encoding=utf-8
 
-from __future__ import (
-    absolute_import, division, print_function, unicode_literals
-)
 import argparse
 import ast
 import xml.parsers.expat
index 56a0dd2..d6af6e9 100644 (file)
@@ -22,7 +22,6 @@
 # IN THE SOFTWARE.
 #
 
-from __future__ import print_function
 import sys
 import zlib
 import xml.etree.ElementTree as et
index 8a6d2a1..ea81edf 100644 (file)
 
 """Generates isl_format_layout.c."""
 
-from __future__ import absolute_import, division, print_function
 import argparse
 import csv
 import re
 
 from mako import template
 
-# Load the template, ensure that __future__.division is imported, and set the
-# bytes encoding to be utf-8. This last bit is important to getting simple
-# consistent behavior for python 3 when we get there.
-TEMPLATE = template.Template(future_imports=['division'],
-                             output_encoding='utf-8',
+# Load the template and set the bytes encoding to be utf-8.
+TEMPLATE = template.Template(output_encoding='utf-8',
                              text="""\
 /* This file is autogenerated by gen_format_layout.py. DO NOT EDIT! */
 
index 0559dd1..dba393d 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 import gl_XML, glX_XML
 
 
index a55c737..d37ac6a 100644 (file)
@@ -26,8 +26,6 @@
 #    Ian Romanick <idr@us.ibm.com>
 #    Jeremy Kolb <jkolb@brandeis.edu>
 
-from __future__ import division, print_function
-
 import argparse
 
 import gl_XML, glX_XML, glX_proto_common, license
index 2a843c3..37c896b 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 import argparse
 import sys, string
 
index 34e83ad..d2f9fcd 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 import argparse
 
 import license
index da80ea1..3488000 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 from collections import OrderedDict
 from decimal import Decimal
 import xml.etree.ElementTree as ET
index f4870be..4e93eda 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 import argparse
 
 import gl_XML, glX_XML
index 1e4d5a3..02cc2bf 100644 (file)
@@ -25,8 +25,6 @@
 # Authors:
 #    Zack Rusin <zack@kde.org>
 
-from __future__ import print_function
-
 import argparse
 
 import license
index 8bca9ed..99e7dc6 100644 (file)
@@ -24,8 +24,6 @@
 # _mesa_initialize_exec_table().  It is responsible for populating all
 # entries in the "exec" dispatch table that aren't dynamic.
 
-from __future__ import print_function
-
 import argparse
 import collections
 import license
index 92e1a54..4695614 100644 (file)
@@ -29,8 +29,6 @@
 # Based on code ogiginally by:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 import argparse
 
 import license
index a73745b..39b5aa2 100644 (file)
@@ -20,8 +20,6 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-from __future__ import print_function
-
 import contextlib
 import getopt
 import gl_XML
index b87b790..c45b848 100644 (file)
@@ -20,8 +20,6 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-from __future__ import print_function
-
 import getopt
 import gl_XML
 import license
index 6a95049..32c60e8 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 import argparse
 
 import license
index e32139e..659e177 100644 (file)
@@ -25,8 +25,6 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 import argparse
 
 import gl_XML
index b4149a5..487843d 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 import argparse
 import copy
 
index 3d262cf..4b10db3 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 import argparse
 
 import license
index 0740b18..dae9552 100644 (file)
@@ -23,8 +23,6 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
-from __future__ import print_function
-
 import argparse
 
 import license
index 1f710ea..a5c47cd 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-from __future__ import print_function
-
 import copy
 
 class type_node(object):
index a002300..deb3ee2 100644 (file)
@@ -24,8 +24,6 @@
 # Authors:
 #    Chia-I Wu <olv@lunarg.com>
 
-from __future__ import print_function
-
 import sys
 # make it possible to import glapi
 import os
index edc0324..37b46a2 100644 (file)
@@ -21,8 +21,6 @@
 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-from __future__ import division, print_function
-
 import format_parser as parser
 import sys
 
index 3e9032b..fb006ad 100644 (file)
@@ -28,8 +28,6 @@
 # Generate a C header file containing hash tables of glGet parameter
 # names for each GL API. The generated file is to be included by glGet.c
 
-from __future__ import print_function
-
 import os, sys, getopt
 from collections import defaultdict
 import get_hash_params
index e32c01f..2ef33f9 100644 (file)
  */
 '''
 
-
-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'''
@@ -220,7 +211,7 @@ def truncate_mantissa(x, bits):
     '''Truncate an integer so it can be represented exactly with a floating
     point mantissa'''
 
-    assert isinstance(x, integer_types)
+    assert isinstance(x, int)
 
     s = 1
     if x < 0:
@@ -244,7 +235,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, integer_types):
+            and isinstance(value, int):
             return truncate_mantissa(value, 23)
         return value
     if type.type == FIXED:
index 9d6ca26..8571a0f 100644 (file)
@@ -29,7 +29,6 @@
 '''
 
 
-from __future__ import division
 import copy
 
 VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5)
index 6bfccef..10659d5 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
 CopyRight = '''
 /**************************************************************************
  *
index 98fa1c4..f52455c 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import print_function
-
 CopyRight = '''
 /**************************************************************************
  *
index efff14d..e5c0e9d 100644 (file)
@@ -22,7 +22,6 @@
 
 # Converts a file to a C/C++ #include containing a string
 
-from __future__ import unicode_literals
 import argparse
 import io
 import os
index 01f0551..5fff82d 100644 (file)
@@ -21,7 +21,6 @@
 
 """Create enum to string functions for vulkan using vk.xml."""
 
-from __future__ import print_function
 import argparse
 import os
 import textwrap