[pypy-commit] pypy py3k: test_md5 now passes
amauryfa
noreply at buildbot.pypy.org
Thu Oct 13 22:40:22 CEST 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r48028:f76981eb4678
Date: 2011-10-13 22:38 +0200
http://bitbucket.org/pypy/pypy/changeset/f76981eb4678/
Log: test_md5 now passes
diff --git a/lib_pypy/binascii.py b/lib_pypy/binascii.py
--- a/lib_pypy/binascii.py
+++ b/lib_pypy/binascii.py
@@ -656,7 +656,7 @@
result = 0
crc = ~long(crc) & 0xffffffffL
for c in s:
- crc = crc_32_tab[(crc ^ long(ord(c))) & 0xffL] ^ (crc >> 8)
+ crc = crc_32_tab[(crc ^ c) & 0xffL] ^ (crc >> 8)
#/* Note: (crc >> 8) MUST zero fill on left
result = crc ^ 0xffffffffL
@@ -669,19 +669,19 @@
def b2a_hex(s):
result = []
for char in s:
- c = (ord(char) >> 4) & 0xf
+ c = (char >> 4) & 0xf
if c > 9:
c = c + ord('a') - 10
else:
c = c + ord('0')
result.append(chr(c))
- c = ord(char) & 0xf
+ c = char & 0xf
if c > 9:
c = c + ord('a') - 10
else:
c = c + ord('0')
- result.append(chr(c))
- return ''.join(result)
+ result.append(c)
+ return bytes(result)
hexlify = b2a_hex
@@ -713,8 +713,8 @@
for a, b in pairs_gen(t):
if a < 0 or b < 0:
raise TypeError('Non-hexadecimal digit found')
- result.append(chr((a << 4) + b))
- return ''.join(result)
+ result.append((a << 4) + b)
+ return bytes(result)
unhexlify = a2b_hex
diff --git a/pypy/module/_md5/test/test_md5.py b/pypy/module/_md5/test/test_md5.py
--- a/pypy/module/_md5/test/test_md5.py
+++ b/pypy/module/_md5/test/test_md5.py
@@ -65,7 +65,7 @@
for input, expected in cases:
d = md5.md5(input)
assert d.hexdigest() == expected
- assert d.digest() == binascii.hexlify(expected.encode('ascii'))
+ assert d.digest() == binascii.unhexlify(expected.encode('ascii'))
def test_copy(self):
@@ -87,8 +87,8 @@
Test passing a buffer object.
"""
md5 = self.md5
- d1 = md5.md5(buffer("abcde"))
- d1.update(buffer("jkl"))
+ d1 = md5.md5(buffer(b"abcde"))
+ d1.update(buffer(b"jkl"))
assert d1.hexdigest() == 'e570e7110ecef72fcb772a9c05d03373'
@@ -97,7 +97,6 @@
Test passing unicode strings.
"""
md5 = self.md5
- d1 = md5.md5(u"abcde")
- d1.update(u"jkl")
- assert d1.hexdigest() == 'e570e7110ecef72fcb772a9c05d03373'
- raises(UnicodeEncodeError, d1.update, u'\xe9')
+ raises(TypeError, md5.md5, "abcde")
+ d1 = md5.md5()
+ raises(TypeError, d1.update, "jkl")
More information about the pypy-commit
mailing list