Ticket #42071: patch-python3-fixes.diff

File patch-python3-fixes.diff, 4.4 KB (added by zpeeters@…, 10 years ago)
  • src/mapi/mapi/mapi_abi.py

    a b  
    3838# number of dynamic entries
    3939ABI_NUM_DYNAMIC_ENTRIES = 256
    4040
     41from functools import total_ordering
     42@total_ordering
    4143class ABIEntry(object):
    4244    """Represent an ABI entry."""
    4345
     
    130132                res = cmp(self.name, other.name)
    131133
    132134        return res
     135   
     136    def __lt__(self, other):
     137        if self.slot == other.slot:
     138            if self.alias == other.alias:
     139                return self.name < other.name
     140            else:
     141                return self.alias < other.alias
     142        else:
     143            return self.slot < other.slot
     144   
    133145
    134146def abi_parse_xml(xml):
    135147    """Parse a GLAPI XML file for ABI entries."""
     
    292304
    293305        # sort entries by their names
    294306        self.entries_sorted_by_names = self.entries[:]
    295         self.entries_sorted_by_names.sort(lambda x, y: cmp(x.name, y.name))
     307        self.entries_sorted_by_names.sort(key=lambda x: x.name)
    296308
    297309        self.indent = ' ' * 3
    298310        self.noop_warn = 'noop_warn'
     
    471483        """Return the string pool for use by stubs."""
    472484        # sort entries by their names
    473485        sorted_entries = self.entries[:]
    474         sorted_entries.sort(lambda x, y: cmp(x.name, y.name))
     486        sorted_entries.sort(key=lambda x: x.name)
    475487
    476488        pool = []
    477489        offsets = {}
  • src/glsl/builtins/tools/generate_builtins.py

    a b  
    6161def run_compiler(args):
    6262    command = [compiler, '--dump-lir'] + args
    6363    p = Popen(command, 1, stdout=PIPE, shell=False)
    64     output = p.communicate()[0]
     64    output = p.communicate()[0].decode('utf-8')
    6565
    6666    # Clean up output a bit by killing whitespace before a closing paren.
    6767    kill_paren_whitespace = re.compile(r'[ \n]*\)', re.MULTILINE)
  • src/mapi/glapi/gen/typeexpr.py

    a b  
    2525# Authors:
    2626#    Ian Romanick <idr@us.ibm.com>
    2727
    28 import string, copy
     28import copy
    2929
    3030class type_node:
    3131        def __init__(self):
     
    125125
    126126                # Replace '*' with ' * ' in type_string.  Then, split the string
    127127                # into tokens, separated by spaces.
    128                 tokens = string.split( string.replace( type_string, "*", " * " ) )
     128                tokens = type_string.replace("*", " * ").split()
    129129
    130130                const = 0
    131131                t = None
  • src/mapi/glapi/gen/gl_XML.py

    a b  
    2626#    Ian Romanick <idr@us.ibm.com>
    2727
    2828import libxml2
    29 import re, sys, string
     29import re, sys
    3030import typeexpr
    3131
    3232
     
    319319
    320320        if len(list) == 0: list = ["void"]
    321321
    322         return string.join(list, ", ")
     322        return ", ".join(list)
    323323
    324324
    325325class gl_item:
     
    575575                                list.append( str(s) )
    576576
    577577                        if len(list) > 1 and use_parens :
    578                                 return "(%s)" % (string.join(list, " * "))
     578                                return "(%s)" % (" * ".join(list))
    579579                        else:
    580                                 return string.join(list, " * ")
     580                                return " * ".join(list)
    581581
    582582                elif self.is_image():
    583583                        return "compsize"
  • src/gallium/auxiliary/util/u_format_pack.py

    a b  
    215215    if type.type == FLOAT:
    216216        return value
    217217    if type.type == FIXED:
    218         return int(value * (1 << (type.size/2)))
     218        return int(value * (1 << (type.size//2)))
    219219    if not type.norm:
    220220        return int(value)
    221221    if type.type == UNSIGNED:
  • src/gallium/auxiliary/util/u_format_parse.py

    a b  
    7777        if self.type == FLOAT:
    7878            return VERY_LARGE
    7979        if self.type == FIXED:
    80             return (1 << (self.size/2)) - 1
     80            return (1 << (self.size//2)) - 1
    8181        if self.norm:
    8282            return 1
    8383        if self.type == UNSIGNED:
     
    9191        if self.type == FLOAT:
    9292            return -VERY_LARGE
    9393        if self.type == FIXED:
    94             return -(1 << (self.size/2))
     94            return -(1 << (self.size//2))
    9595        if self.type == UNSIGNED:
    9696            return 0
    9797        if self.norm: