]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Make time_independent_equals work with python3 byte strings
authorBen Darnell <ben@bendarnell.com>
Thu, 24 Feb 2011 23:11:38 +0000 (15:11 -0800)
committerBen Darnell <ben@bendarnell.com>
Thu, 24 Feb 2011 23:11:38 +0000 (15:11 -0800)
tornado/web.py

index 50de8fccc769e7ae865181ac30839d727674ad9c..43721dab0f79fecdcb8753aeb42e3bdf4f777e79 100644 (file)
@@ -1627,8 +1627,12 @@ def _time_independent_equals(a, b):
     if len(a) != len(b):
         return False
     result = 0
-    for x, y in zip(a, b):
-        result |= ord(x) ^ ord(y)
+    if type(a[0]) is int:  # python3 byte strings
+        for x, y in zip(a,b):
+            result |= x ^ y
+    else:  # python2
+        for x, y in zip(a, b):
+            result |= ord(x) ^ ord(y)
     return result == 0