--- a/src/mapi/mapi/mapi_abi.py	2012-03-23 01:10:07.000000000 +0800
+++ b/src/mapi/mapi/mapi_abi.py	2014-01-02 19:20:27.000000000 +0800
@@ -38,6 +38,8 @@
 # number of dynamic entries
 ABI_NUM_DYNAMIC_ENTRIES = 256
 
+from functools import total_ordering
+@total_ordering
 class ABIEntry(object):
     """Represent an ABI entry."""
 
@@ -130,6 +132,16 @@
                 res = cmp(self.name, other.name)
 
         return res
+    
+    def __lt__(self, other):
+        if self.slot == other.slot:
+            if self.alias == other.alias:
+                return self.name < other.name
+            else:
+                return self.alias < other.alias
+        else:
+            return self.slot < other.slot
+    
 
 def abi_parse_xml(xml):
     """Parse a GLAPI XML file for ABI entries."""
@@ -292,7 +304,7 @@
 
         # sort entries by their names
         self.entries_sorted_by_names = self.entries[:]
-        self.entries_sorted_by_names.sort(lambda x, y: cmp(x.name, y.name))
+        self.entries_sorted_by_names.sort(key=lambda x: x.name)
 
         self.indent = ' ' * 3
         self.noop_warn = 'noop_warn'
@@ -471,7 +483,7 @@
         """Return the string pool for use by stubs."""
         # sort entries by their names
         sorted_entries = self.entries[:]
-        sorted_entries.sort(lambda x, y: cmp(x.name, y.name))
+        sorted_entries.sort(key=lambda x: x.name)
 
         pool = []
         offsets = {}
--- a/src/glsl/builtins/tools/generate_builtins.py	2012-03-23 01:10:07.000000000 +0800
+++ b/src/glsl/builtins/tools/generate_builtins.py	2014-01-02 22:42:54.000000000 +0800
@@ -61,7 +61,7 @@
 def run_compiler(args):
     command = [compiler, '--dump-lir'] + args
     p = Popen(command, 1, stdout=PIPE, shell=False)
-    output = p.communicate()[0]
+    output = p.communicate()[0].decode('utf-8')
 
     # Clean up output a bit by killing whitespace before a closing paren.
     kill_paren_whitespace = re.compile(r'[ \n]*\)', re.MULTILINE)
--- a/src/mapi/glapi/gen/typeexpr.py	2011-12-08 07:54:22.000000000 +0800
+++ b/src/mapi/glapi/gen/typeexpr.py	2014-01-02 22:48:43.000000000 +0800
@@ -25,7 +25,7 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
-import string, copy
+import copy
 
 class type_node:
 	def __init__(self):
@@ -125,7 +125,7 @@
 
 		# Replace '*' with ' * ' in type_string.  Then, split the string
 		# into tokens, separated by spaces.
-		tokens = string.split( string.replace( type_string, "*", " * " ) )
+		tokens = type_string.replace("*", " * ").split()
 
 		const = 0
 		t = None
--- a/src/mapi/glapi/gen/gl_XML.py	2012-03-23 01:10:07.000000000 +0800
+++ b/src/mapi/glapi/gen/gl_XML.py	2014-01-02 22:51:53.000000000 +0800
@@ -26,7 +26,7 @@
 #    Ian Romanick <idr@us.ibm.com>
 
 import libxml2
-import re, sys, string
+import re, sys
 import typeexpr
 
 
@@ -319,7 +319,7 @@
 
 	if len(list) == 0: list = ["void"]
 
-	return string.join(list, ", ")
+	return ", ".join(list)
 
 
 class gl_item:
@@ -575,9 +575,9 @@
 				list.append( str(s) )
 
 			if len(list) > 1 and use_parens :
-				return "(%s)" % (string.join(list, " * "))
+				return "(%s)" % (" * ".join(list))
 			else:
-				return string.join(list, " * ")
+				return " * ".join(list)
 
 		elif self.is_image():
 			return "compsize"
--- a/src/gallium/auxiliary/util/u_format_pack.py	2012-03-23 01:10:07.000000000 +0800
+++ b/src/gallium/auxiliary/util/u_format_pack.py	2014-01-02 22:55:07.000000000 +0800
@@ -215,7 +215,7 @@
     if type.type == FLOAT:
         return value
     if type.type == FIXED:
-        return int(value * (1 << (type.size/2)))
+        return int(value * (1 << (type.size//2)))
     if not type.norm:
         return int(value)
     if type.type == UNSIGNED:
--- a/src/gallium/auxiliary/util/u_format_parse.py	2012-03-23 01:10:07.000000000 +0800
+++ b/src/gallium/auxiliary/util/u_format_parse.py	2014-01-02 22:55:30.000000000 +0800
@@ -77,7 +77,7 @@
         if self.type == FLOAT:
             return VERY_LARGE
         if self.type == FIXED:
-            return (1 << (self.size/2)) - 1
+            return (1 << (self.size//2)) - 1
         if self.norm:
             return 1
         if self.type == UNSIGNED:
@@ -91,7 +91,7 @@
         if self.type == FLOAT:
             return -VERY_LARGE
         if self.type == FIXED:
-            return -(1 << (self.size/2))
+            return -(1 << (self.size//2))
         if self.type == UNSIGNED:
             return 0
         if self.norm:
