Author: Manuel Jacob <m...@manueljacob.de> Branch: py3.5 Changeset: r91120:bff93f299782 Date: 2017-04-23 23:38 +0200 http://bitbucket.org/pypy/pypy/changeset/bff93f299782/
Log: 2to3 diff --git a/lib_pypy/_md5.py b/lib_pypy/_md5.py --- a/lib_pypy/_md5.py +++ b/lib_pypy/_md5.py @@ -53,10 +53,10 @@ j = 0 i = 0 while i < imax: - b0 = ord(list[j]) - b1 = ord(list[j+1]) << 8 - b2 = ord(list[j+2]) << 16 - b3 = ord(list[j+3]) << 24 + b0 = list[j] + b1 = list[j+1] << 8 + b2 = list[j+2] << 16 + b3 = list[j+3] << 24 hl[i] = b0 | b1 |b2 | b3 i = i+1 j = j+4 @@ -319,7 +319,7 @@ else: padLen = 120 - index - padding = [b'\200'] + [b'\000'] * 63 + padding = [128] + [0] * 63 self.update(padding[:padLen]) # Append length (before padding). diff --git a/pypy/module/test_lib_pypy/test_md5_extra.py b/pypy/module/test_lib_pypy/test_md5_extra.py --- a/pypy/module/test_lib_pypy/test_md5_extra.py +++ b/pypy/module/test_lib_pypy/test_md5_extra.py @@ -36,32 +36,32 @@ def test_update(self): """Test updating cloned objects.""" cases = ( - "123", - "1234", - "12345", - "123456", - "1234567", - "12345678", - "123456789 123456789 123456789 ", - "123456789 123456789 ", - "123456789 123456789 1", - "123456789 123456789 12", - "123456789 123456789 123", - "123456789 123456789 1234", - "123456789 123456789 123456789 1", - "123456789 123456789 123456789 12", - "123456789 123456789 123456789 123", - "123456789 123456789 123456789 1234", - "123456789 123456789 123456789 12345", - "123456789 123456789 123456789 123456", - "123456789 123456789 123456789 1234567", - "123456789 123456789 123456789 12345678", + b"123", + b"1234", + b"12345", + b"123456", + b"1234567", + b"12345678", + b"123456789 123456789 123456789 ", + b"123456789 123456789 ", + b"123456789 123456789 1", + b"123456789 123456789 12", + b"123456789 123456789 123", + b"123456789 123456789 1234", + b"123456789 123456789 123456789 1", + b"123456789 123456789 123456789 12", + b"123456789 123456789 123456789 123", + b"123456789 123456789 123456789 1234", + b"123456789 123456789 123456789 12345", + b"123456789 123456789 123456789 123456", + b"123456789 123456789 123456789 1234567", + b"123456789 123456789 123456789 12345678", ) space = self.space w__md5 = import_lib_pypy(space, '_md5') # Load both with same prefix. - prefix1 = 2**10 * 'a' + prefix1 = 2**10 * b'a' # The host md5 m1 = md5.md5() @@ -70,7 +70,7 @@ # The app-level _md5 w_m2 = space.call_method(w__md5, 'md5') - space.call_method(w_m2, 'update', space.wrap(prefix1)) + space.call_method(w_m2, 'update', space.newbytes(prefix1)) w_m2c = space.call_method(w_m2, 'copy') # Update and compare... @@ -78,7 +78,7 @@ m1c.update(message) d1 = m1c.hexdigest() - space.call_method(w_m2c, 'update', space.wrap(message)) + space.call_method(w_m2c, 'update', space.newbytes(message)) w_d2 = space.call_method(w_m2c, 'hexdigest') d2 = space.str_w(w_d2) @@ -136,19 +136,19 @@ def test1(self): """Test cases with known digest result.""" cases = ( - ("", + (b"", "d41d8cd98f00b204e9800998ecf8427e"), - ("a", + (b"a", "0cc175b9c0f1b6a831c399e269772661"), - ("abc", + (b"abc", "900150983cd24fb0d6963f7d28e17f72"), - ("message digest", + (b"message digest", "f96b697d7cb7938d525a2f31aaf161d0"), - ("abcdefghijklmnopqrstuvwxyz", + (b"abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b"), - ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + (b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "d174ab98d277d9f5a5611c2c9f419d9f"), - ("1234567890"*8, + (b"1234567890"*8, "57edf4a22be3c955ac49da2e2107b67a"), ) @@ -162,26 +162,26 @@ def test2(self): """Test cases without known digest result.""" cases = ( - "123", - "1234", - "12345", - "123456", - "1234567", - "12345678", - "123456789 123456789 123456789 ", - "123456789 123456789 ", - "123456789 123456789 1", - "123456789 123456789 12", - "123456789 123456789 123", - "123456789 123456789 1234", - "123456789 123456789 123456789 1", - "123456789 123456789 123456789 12", - "123456789 123456789 123456789 123", - "123456789 123456789 123456789 1234", - "123456789 123456789 123456789 12345", - "123456789 123456789 123456789 123456", - "123456789 123456789 123456789 1234567", - "123456789 123456789 123456789 12345678", + b"123", + b"1234", + b"12345", + b"123456", + b"1234567", + b"12345678", + b"123456789 123456789 123456789 ", + b"123456789 123456789 ", + b"123456789 123456789 1", + b"123456789 123456789 12", + b"123456789 123456789 123", + b"123456789 123456789 1234", + b"123456789 123456789 123456789 1", + b"123456789 123456789 123456789 12", + b"123456789 123456789 123456789 123", + b"123456789 123456789 123456789 1234", + b"123456789 123456789 123456789 12345", + b"123456789 123456789 123456789 123456", + b"123456789 123456789 123456789 1234567", + b"123456789 123456789 123456789 12345678", ) for message in cases: @@ -194,9 +194,9 @@ def test3(self): """Test cases with long messages (can take a while).""" cases = ( - 2**10*'a', - 2**10*'abcd', - #2**20*'a', # 1 MB, takes about 160 sec. on a 233 Mhz Pentium. + 2**10*b'a', + 2**10*b'abcd', + #2**20*b'a', # 1 MB, takes about 160 sec. on a 233 Mhz Pentium. ) for message in cases: @@ -210,7 +210,7 @@ """Test cases with increasingly growing message lengths.""" i = 0 while i < 2**5: - message = i * 'a' + message = i * b'a' res = self.compare(message) if res is not None: d1, d2 = res _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit