whirlpool.py: fix for python3
authorZac Medico <zmedico@gentoo.org>
Wed, 5 Oct 2011 00:59:30 +0000 (17:59 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 5 Oct 2011 00:59:30 +0000 (17:59 -0700)
pym/portage/util/whirlpool.py

index 399958a1f6a331cb85afcb5699ec39c9111ca8b9..c5c2b376512b29277ba555664dc8977701718723 100644 (file)
@@ -639,7 +639,8 @@ def WhirlpoolInit(ctx):
     return
 
 def WhirlpoolAdd(source, sourceBits, ctx):
-    source = [ord(s)&0xff for s in source]
+    if sys.hexversion < 0x3000000:
+        source = [ord(s)&0xff for s in source]
 
     carry = 0
     value = sourceBits
@@ -785,9 +786,9 @@ def processBuffer(ctx):
 #
 
 if __name__ == '__main__':
-       assert Whirlpool('The quick brown fox jumps over the lazy dog').hexdigest() == \
+       assert Whirlpool(b'The quick brown fox jumps over the lazy dog').hexdigest() == \
                'b97de512e91e3828b40d2b0fdce9ceb3c4a71f9bea8d88e75c4fa854df36725fd2b52eb6544edcacd6f8beddfea403cb55ae31f03ad62a5ef54e42ee82c3fb35'
-       assert Whirlpool('The quick brown fox jumps over the lazy eog').hexdigest() == \
+       assert Whirlpool(b'The quick brown fox jumps over the lazy eog').hexdigest() == \
                'c27ba124205f72e6847f3e19834f925cc666d0974167af915bb462420ed40cc50900d85a1f923219d832357750492d5c143011a76988344c2635e69d06f2d38c'
-       assert Whirlpool('').hexdigest() == \
+       assert Whirlpool(b'').hexdigest() == \
                '19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3'