Commits

Armin Rigo committed ba9640d

Python 3 compat

Comments (0)

Files changed (1)

             return eval('u'+repr(other).replace(r'\\u', r'\u')
                                        .replace(r'\\U', r'\U'))
     u = U()
+    str2bytes = str
 else:
     type_or_class = "class"
     long = int
     bytechr = lambda n: bytes([n])
     bitem2bchr = bytechr
     u = ""
+    str2bytes = lambda s: bytes(s, "ascii")
 
 def size_of_int():
     BInt = new_primitive_type("int")
     BCharArray = new_array_type(BCharP, None)
     buflist = []
     for i in range(20):
-        c = newp(BCharArray, b"hi there %d" % i)
+        c = newp(BCharArray, str2bytes("hi there %d" % i))
         buflist.append(buffer(c))
     import gc; gc.collect()
     for i in range(20):
         buf = buflist[i]
-        assert buf[:] == b"hi there %d\x00" % i
+        assert buf[:] == str2bytes("hi there %d\x00" % i)