[pypy-commit] pypy default: port some lib_pypy cleanups/fixes/modernizations from py3k
bdkearns
noreply at buildbot.pypy.org
Fri Mar 8 06:43:50 CET 2013
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r62210:42658a039a09
Date: 2013-03-08 00:25 -0500
http://bitbucket.org/pypy/pypy/changeset/42658a039a09/
Log: port some lib_pypy cleanups/fixes/modernizations from py3k
diff --git a/lib_pypy/__init__.py b/lib_pypy/__init__.py
--- a/lib_pypy/__init__.py
+++ b/lib_pypy/__init__.py
@@ -1,4 +1,4 @@
# This __init__.py shows up in PyPy's app-level standard library.
# Let's try to prevent that confusion...
if __name__ != 'lib_pypy':
- raise ImportError, '__init__'
+ raise ImportError('__init__')
diff --git a/lib_pypy/_collections.py b/lib_pypy/_collections.py
--- a/lib_pypy/_collections.py
+++ b/lib_pypy/_collections.py
@@ -10,7 +10,7 @@
import operator
try:
- from thread import get_ident as _thread_ident
+ from threading import _get_ident as _thread_ident
except ImportError:
def _thread_ident():
return -1
@@ -97,7 +97,7 @@
def pop(self):
if self.left is self.right and self.leftndx > self.rightndx:
- raise IndexError, "pop from an empty deque"
+ raise IndexError("pop from an empty deque")
x = self.right[self.rightndx]
self.right[self.rightndx] = None
self.length -= 1
@@ -118,7 +118,7 @@
def popleft(self):
if self.left is self.right and self.leftndx > self.rightndx:
- raise IndexError, "pop from an empty deque"
+ raise IndexError("pop from an empty deque")
x = self.left[self.leftndx]
self.left[self.leftndx] = None
self.length -= 1
@@ -322,7 +322,7 @@
return type(self), (list(self), self.maxlen)
def __hash__(self):
- raise TypeError, "deque objects are unhashable"
+ raise TypeError("deque objects are unhashable")
def __copy__(self):
return self.__class__(self, self.maxlen)
@@ -374,11 +374,11 @@
self.counter = len(deq)
def giveup():
self.counter = 0
- raise RuntimeError, "deque mutated during iteration"
+ raise RuntimeError("deque mutated during iteration")
self._gen = itergen(deq.state, giveup)
def next(self):
- res = self._gen.next()
+ res = next(self._gen)
self.counter -= 1
return res
diff --git a/lib_pypy/_csv.py b/lib_pypy/_csv.py
--- a/lib_pypy/_csv.py
+++ b/lib_pypy/_csv.py
@@ -225,7 +225,7 @@
self._parse_reset()
while True:
try:
- line = self.input_iter.next()
+ line = next(self.input_iter)
except StopIteration:
# End of input OR exception
if len(self.field) > 0:
diff --git a/lib_pypy/_marshal.py b/lib_pypy/_marshal.py
--- a/lib_pypy/_marshal.py
+++ b/lib_pypy/_marshal.py
@@ -3,9 +3,17 @@
This module contains functions that can read and write Python values in a binary format. The format is specific to Python, but independent of machine architecture issues (e.g., you can write a Python value to a file on a PC, transport the file to a Sun, and read it back there). Details of the format may change between Python versions.
"""
+# NOTE: This module is used in the Python3 interpreter, but also by
+# the "sandboxed" process. It must work for Python2 as well.
+
import types
from _codecs import utf_8_decode, utf_8_encode
+try:
+ intern
+except NameError:
+ from sys import intern
+
try: from __pypy__ import builtinify
except ImportError: builtinify = lambda f: f
@@ -49,7 +57,7 @@
if func:
break
else:
- raise ValueError, "unmarshallable object"
+ raise ValueError("unmarshallable object")
func(self, x)
def w_long64(self, x):
@@ -72,7 +80,7 @@
def dump_none(self, x):
self._write(TYPE_NONE)
- dispatch[types.NoneType] = dump_none
+ dispatch[type(None)] = dump_none
def dump_bool(self, x):
if x:
@@ -83,7 +91,7 @@
def dump_stopiter(self, x):
if x is not StopIteration:
- raise ValueError, "unmarshallable object"
+ raise ValueError("unmarshallable object")
self._write(TYPE_STOPITER)
dispatch[type(StopIteration)] = dump_stopiter
@@ -91,10 +99,11 @@
self._write(TYPE_ELLIPSIS)
try:
- dispatch[types.EllipsisType] = dump_ellipsis
+ dispatch[type(Ellipsis)] = dump_ellipsis
except NameError:
pass
+ # In Python3, this function is not used; see dump_long() below.
def dump_int(self, x):
y = x>>31
if y and y != -1:
@@ -103,7 +112,7 @@
else:
self._write(TYPE_INT)
self.w_long(x)
- dispatch[types.IntType] = dump_int
+ dispatch[int] = dump_int
def dump_long(self, x):
self._write(TYPE_LONG)
@@ -118,27 +127,32 @@
self.w_long(len(digits) * sign)
for d in digits:
self.w_short(d)
- dispatch[types.LongType] = dump_long
+ try:
+ long
+ except NameError:
+ dispatch[int] = dump_long
+ else:
+ dispatch[long] = dump_long
def dump_float(self, x):
write = self._write
write(TYPE_FLOAT)
- s = `x`
+ s = repr(x)
write(chr(len(s)))
write(s)
- dispatch[types.FloatType] = dump_float
+ dispatch[float] = dump_float
def dump_complex(self, x):
write = self._write
write(TYPE_COMPLEX)
- s = `x.real`
+ s = repr(x.real)
write(chr(len(s)))
write(s)
- s = `x.imag`
+ s = repr(x.imag)
write(chr(len(s)))
write(s)
try:
- dispatch[types.ComplexType] = dump_complex
+ dispatch[complex] = dump_complex
except NameError:
pass
@@ -148,7 +162,7 @@
self._write(TYPE_STRING)
self.w_long(len(x))
self._write(x)
- dispatch[types.StringType] = dump_string
+ dispatch[bytes] = dump_string
def dump_unicode(self, x):
self._write(TYPE_UNICODE)
@@ -156,21 +170,26 @@
s, len_s = utf_8_encode(x)
self.w_long(len_s)
self._write(s)
- dispatch[types.UnicodeType] = dump_unicode
+ try:
+ unicode
+ except NameError:
+ dispatch[str] = dump_unicode
+ else:
+ dispatch[unicode] = dump_unicode
def dump_tuple(self, x):
self._write(TYPE_TUPLE)
self.w_long(len(x))
for item in x:
self.dump(item)
- dispatch[types.TupleType] = dump_tuple
+ dispatch[tuple] = dump_tuple
def dump_list(self, x):
self._write(TYPE_LIST)
self.w_long(len(x))
for item in x:
self.dump(item)
- dispatch[types.ListType] = dump_list
+ dispatch[list] = dump_list
def dump_dict(self, x):
self._write(TYPE_DICT)
@@ -178,7 +197,7 @@
self.dump(key)
self.dump(value)
self._write(TYPE_NULL)
- dispatch[types.DictionaryType] = dump_dict
+ dispatch[dict] = dump_dict
def dump_code(self, x):
self._write(TYPE_CODE)
@@ -252,7 +271,7 @@
try:
return self.dispatch[c](self)
except KeyError:
- raise ValueError, "bad marshal code: %c (%d)" % (c, ord(c))
+ raise ValueError("bad marshal code: %c (%d)" % (c, ord(c)))
def r_short(self):
lo = ord(self._read(1))
@@ -270,7 +289,7 @@
d = ord(s[3])
x = a | (b<<8) | (c<<16) | (d<<24)
if d & 0x80 and x > 0:
- x = -((1L<<32) - x)
+ x = -((1<<32) - x)
return int(x)
else:
return x
@@ -280,14 +299,14 @@
b = ord(self._read(1))
c = ord(self._read(1))
d = ord(self._read(1))
- e = long(ord(self._read(1)))
- f = long(ord(self._read(1)))
- g = long(ord(self._read(1)))
- h = long(ord(self._read(1)))
+ e = ord(self._read(1))
+ f = ord(self._read(1))
+ g = ord(self._read(1))
+ h = ord(self._read(1))
x = a | (b<<8) | (c<<16) | (d<<24)
x = x | (e<<32) | (f<<40) | (g<<48) | (h<<56)
if h & 0x80 and x > 0:
- x = -((1L<<64) - x)
+ x = -((1<<64) - x)
return x
def load_null(self):
@@ -324,10 +343,10 @@
if size < 0:
sign = -1
size = -size
- x = 0L
+ x = 0
for i in range(size):
d = self.r_short()
- x = x | (d<<(i*15L))
+ x = x | (d<<(i*15))
return x * sign
dispatch[TYPE_LONG] = load_long
@@ -459,7 +478,7 @@
self.bufpos += 4
x = a | (b<<8) | (c<<16) | (d<<24)
if d & 0x80 and x > 0:
- x = -((1L<<32) - x)
+ x = -((1<<32) - x)
return int(x)
else:
return x
@@ -469,14 +488,14 @@
b = ord(_read1(self))
c = ord(_read1(self))
d = ord(_read1(self))
- e = long(ord(_read1(self)))
- f = long(ord(_read1(self)))
- g = long(ord(_read1(self)))
- h = long(ord(_read1(self)))
+ e = ord(_read1(self))
+ f = ord(_read1(self))
+ g = ord(_read1(self))
+ h = ord(_read1(self))
x = a | (b<<8) | (c<<16) | (d<<24)
x = x | (e<<32) | (f<<40) | (g<<48) | (h<<56)
if h & 0x80 and x > 0:
- x = -((1L<<64) - x)
+ x = -((1<<64) - x)
return x
_load_dispatch = {}
@@ -498,7 +517,7 @@
self.bufpos += 1
return _load_dispatch[c](self)
except KeyError:
- raise ValueError, "bad marshal code: %c (%d)" % (c, ord(c))
+ raise ValueError("bad marshal code: %c (%d)" % (c, ord(c)))
except IndexError:
raise EOFError
@@ -540,10 +559,10 @@
if size < 0:
sign = -1
size = -size
- x = 0L
+ x = 0
for i in range(size):
d = _r_short(self)
- x = x | (d<<(i*15L))
+ x = x | (d<<(i*15))
return x * sign
dispatch[TYPE_LONG] = load_long
diff --git a/lib_pypy/_md5.py b/lib_pypy/_md5.py
--- a/lib_pypy/_md5.py
+++ b/lib_pypy/_md5.py
@@ -47,16 +47,16 @@
def _bytelist2long(list):
"Transform a list of characters into a list of longs."
- imax = len(list)/4
- hl = [0L] * imax
+ imax = len(list) // 4
+ hl = [0] * imax
j = 0
i = 0
while i < imax:
- b0 = long(ord(list[j]))
- b1 = (long(ord(list[j+1]))) << 8
- b2 = (long(ord(list[j+2]))) << 16
- b3 = (long(ord(list[j+3]))) << 24
+ b0 = ord(list[j])
+ b1 = ord(list[j+1]) << 8
+ b2 = ord(list[j+2]) << 16
+ b3 = ord(list[j+3]) << 24
hl[i] = b0 | b1 |b2 | b3
i = i+1
j = j+4
@@ -100,16 +100,16 @@
(now summed-up in one function).
"""
- res = 0L
+ res = 0
res = res + a + func(b, c, d)
res = res + x
res = res + ac
- res = res & 0xffffffffL
+ res = res & 0xffffffff
res = _rotateLeft(res, s)
- res = res & 0xffffffffL
+ res = res & 0xffffffff
res = res + b
- return res & 0xffffffffL
+ return res & 0xffffffff
class MD5Type:
@@ -122,7 +122,7 @@
"Initialisation."
# Initial message length in bits(!).
- self.length = 0L
+ self.length = 0
self.count = [0, 0]
# Initial empty message as a sequence of bytes (8 bit characters).
@@ -136,15 +136,15 @@
def init(self):
"Initialize the message-digest and set all fields to zero."
- self.length = 0L
+ self.length = 0
self.count = [0, 0]
self.input = []
# Load magic initialization constants.
- self.A = 0x67452301L
- self.B = 0xefcdab89L
- self.C = 0x98badcfeL
- self.D = 0x10325476L
+ self.A = 0x67452301
+ self.B = 0xefcdab89
+ self.C = 0x98badcfe
+ self.D = 0x10325476
def _transform(self, inp):
@@ -161,90 +161,90 @@
S11, S12, S13, S14 = 7, 12, 17, 22
- a = XX(F, a, b, c, d, inp[ 0], S11, 0xD76AA478L) # 1
- d = XX(F, d, a, b, c, inp[ 1], S12, 0xE8C7B756L) # 2
- c = XX(F, c, d, a, b, inp[ 2], S13, 0x242070DBL) # 3
- b = XX(F, b, c, d, a, inp[ 3], S14, 0xC1BDCEEEL) # 4
- a = XX(F, a, b, c, d, inp[ 4], S11, 0xF57C0FAFL) # 5
- d = XX(F, d, a, b, c, inp[ 5], S12, 0x4787C62AL) # 6
- c = XX(F, c, d, a, b, inp[ 6], S13, 0xA8304613L) # 7
- b = XX(F, b, c, d, a, inp[ 7], S14, 0xFD469501L) # 8
- a = XX(F, a, b, c, d, inp[ 8], S11, 0x698098D8L) # 9
- d = XX(F, d, a, b, c, inp[ 9], S12, 0x8B44F7AFL) # 10
- c = XX(F, c, d, a, b, inp[10], S13, 0xFFFF5BB1L) # 11
- b = XX(F, b, c, d, a, inp[11], S14, 0x895CD7BEL) # 12
- a = XX(F, a, b, c, d, inp[12], S11, 0x6B901122L) # 13
- d = XX(F, d, a, b, c, inp[13], S12, 0xFD987193L) # 14
- c = XX(F, c, d, a, b, inp[14], S13, 0xA679438EL) # 15
- b = XX(F, b, c, d, a, inp[15], S14, 0x49B40821L) # 16
+ a = XX(F, a, b, c, d, inp[ 0], S11, 0xD76AA478) # 1
+ d = XX(F, d, a, b, c, inp[ 1], S12, 0xE8C7B756) # 2
+ c = XX(F, c, d, a, b, inp[ 2], S13, 0x242070DB) # 3
+ b = XX(F, b, c, d, a, inp[ 3], S14, 0xC1BDCEEE) # 4
+ a = XX(F, a, b, c, d, inp[ 4], S11, 0xF57C0FAF) # 5
+ d = XX(F, d, a, b, c, inp[ 5], S12, 0x4787C62A) # 6
+ c = XX(F, c, d, a, b, inp[ 6], S13, 0xA8304613) # 7
+ b = XX(F, b, c, d, a, inp[ 7], S14, 0xFD469501) # 8
+ a = XX(F, a, b, c, d, inp[ 8], S11, 0x698098D8) # 9
+ d = XX(F, d, a, b, c, inp[ 9], S12, 0x8B44F7AF) # 10
+ c = XX(F, c, d, a, b, inp[10], S13, 0xFFFF5BB1) # 11
+ b = XX(F, b, c, d, a, inp[11], S14, 0x895CD7BE) # 12
+ a = XX(F, a, b, c, d, inp[12], S11, 0x6B901122) # 13
+ d = XX(F, d, a, b, c, inp[13], S12, 0xFD987193) # 14
+ c = XX(F, c, d, a, b, inp[14], S13, 0xA679438E) # 15
+ b = XX(F, b, c, d, a, inp[15], S14, 0x49B40821) # 16
# Round 2.
S21, S22, S23, S24 = 5, 9, 14, 20
- a = XX(G, a, b, c, d, inp[ 1], S21, 0xF61E2562L) # 17
- d = XX(G, d, a, b, c, inp[ 6], S22, 0xC040B340L) # 18
- c = XX(G, c, d, a, b, inp[11], S23, 0x265E5A51L) # 19
- b = XX(G, b, c, d, a, inp[ 0], S24, 0xE9B6C7AAL) # 20
- a = XX(G, a, b, c, d, inp[ 5], S21, 0xD62F105DL) # 21
- d = XX(G, d, a, b, c, inp[10], S22, 0x02441453L) # 22
- c = XX(G, c, d, a, b, inp[15], S23, 0xD8A1E681L) # 23
- b = XX(G, b, c, d, a, inp[ 4], S24, 0xE7D3FBC8L) # 24
- a = XX(G, a, b, c, d, inp[ 9], S21, 0x21E1CDE6L) # 25
- d = XX(G, d, a, b, c, inp[14], S22, 0xC33707D6L) # 26
- c = XX(G, c, d, a, b, inp[ 3], S23, 0xF4D50D87L) # 27
- b = XX(G, b, c, d, a, inp[ 8], S24, 0x455A14EDL) # 28
- a = XX(G, a, b, c, d, inp[13], S21, 0xA9E3E905L) # 29
- d = XX(G, d, a, b, c, inp[ 2], S22, 0xFCEFA3F8L) # 30
- c = XX(G, c, d, a, b, inp[ 7], S23, 0x676F02D9L) # 31
- b = XX(G, b, c, d, a, inp[12], S24, 0x8D2A4C8AL) # 32
+ a = XX(G, a, b, c, d, inp[ 1], S21, 0xF61E2562) # 17
+ d = XX(G, d, a, b, c, inp[ 6], S22, 0xC040B340) # 18
+ c = XX(G, c, d, a, b, inp[11], S23, 0x265E5A51) # 19
+ b = XX(G, b, c, d, a, inp[ 0], S24, 0xE9B6C7AA) # 20
+ a = XX(G, a, b, c, d, inp[ 5], S21, 0xD62F105D) # 21
+ d = XX(G, d, a, b, c, inp[10], S22, 0x02441453) # 22
+ c = XX(G, c, d, a, b, inp[15], S23, 0xD8A1E681) # 23
+ b = XX(G, b, c, d, a, inp[ 4], S24, 0xE7D3FBC8) # 24
+ a = XX(G, a, b, c, d, inp[ 9], S21, 0x21E1CDE6) # 25
+ d = XX(G, d, a, b, c, inp[14], S22, 0xC33707D6) # 26
+ c = XX(G, c, d, a, b, inp[ 3], S23, 0xF4D50D87) # 27
+ b = XX(G, b, c, d, a, inp[ 8], S24, 0x455A14ED) # 28
+ a = XX(G, a, b, c, d, inp[13], S21, 0xA9E3E905) # 29
+ d = XX(G, d, a, b, c, inp[ 2], S22, 0xFCEFA3F8) # 30
+ c = XX(G, c, d, a, b, inp[ 7], S23, 0x676F02D9) # 31
+ b = XX(G, b, c, d, a, inp[12], S24, 0x8D2A4C8A) # 32
# Round 3.
S31, S32, S33, S34 = 4, 11, 16, 23
- a = XX(H, a, b, c, d, inp[ 5], S31, 0xFFFA3942L) # 33
- d = XX(H, d, a, b, c, inp[ 8], S32, 0x8771F681L) # 34
- c = XX(H, c, d, a, b, inp[11], S33, 0x6D9D6122L) # 35
- b = XX(H, b, c, d, a, inp[14], S34, 0xFDE5380CL) # 36
- a = XX(H, a, b, c, d, inp[ 1], S31, 0xA4BEEA44L) # 37
- d = XX(H, d, a, b, c, inp[ 4], S32, 0x4BDECFA9L) # 38
- c = XX(H, c, d, a, b, inp[ 7], S33, 0xF6BB4B60L) # 39
- b = XX(H, b, c, d, a, inp[10], S34, 0xBEBFBC70L) # 40
- a = XX(H, a, b, c, d, inp[13], S31, 0x289B7EC6L) # 41
- d = XX(H, d, a, b, c, inp[ 0], S32, 0xEAA127FAL) # 42
- c = XX(H, c, d, a, b, inp[ 3], S33, 0xD4EF3085L) # 43
- b = XX(H, b, c, d, a, inp[ 6], S34, 0x04881D05L) # 44
- a = XX(H, a, b, c, d, inp[ 9], S31, 0xD9D4D039L) # 45
- d = XX(H, d, a, b, c, inp[12], S32, 0xE6DB99E5L) # 46
- c = XX(H, c, d, a, b, inp[15], S33, 0x1FA27CF8L) # 47
- b = XX(H, b, c, d, a, inp[ 2], S34, 0xC4AC5665L) # 48
+ a = XX(H, a, b, c, d, inp[ 5], S31, 0xFFFA3942) # 33
+ d = XX(H, d, a, b, c, inp[ 8], S32, 0x8771F681) # 34
+ c = XX(H, c, d, a, b, inp[11], S33, 0x6D9D6122) # 35
+ b = XX(H, b, c, d, a, inp[14], S34, 0xFDE5380C) # 36
+ a = XX(H, a, b, c, d, inp[ 1], S31, 0xA4BEEA44) # 37
+ d = XX(H, d, a, b, c, inp[ 4], S32, 0x4BDECFA9) # 38
+ c = XX(H, c, d, a, b, inp[ 7], S33, 0xF6BB4B60) # 39
+ b = XX(H, b, c, d, a, inp[10], S34, 0xBEBFBC70) # 40
+ a = XX(H, a, b, c, d, inp[13], S31, 0x289B7EC6) # 41
+ d = XX(H, d, a, b, c, inp[ 0], S32, 0xEAA127FA) # 42
+ c = XX(H, c, d, a, b, inp[ 3], S33, 0xD4EF3085) # 43
+ b = XX(H, b, c, d, a, inp[ 6], S34, 0x04881D05) # 44
+ a = XX(H, a, b, c, d, inp[ 9], S31, 0xD9D4D039) # 45
+ d = XX(H, d, a, b, c, inp[12], S32, 0xE6DB99E5) # 46
+ c = XX(H, c, d, a, b, inp[15], S33, 0x1FA27CF8) # 47
+ b = XX(H, b, c, d, a, inp[ 2], S34, 0xC4AC5665) # 48
# Round 4.
S41, S42, S43, S44 = 6, 10, 15, 21
- a = XX(I, a, b, c, d, inp[ 0], S41, 0xF4292244L) # 49
- d = XX(I, d, a, b, c, inp[ 7], S42, 0x432AFF97L) # 50
- c = XX(I, c, d, a, b, inp[14], S43, 0xAB9423A7L) # 51
- b = XX(I, b, c, d, a, inp[ 5], S44, 0xFC93A039L) # 52
- a = XX(I, a, b, c, d, inp[12], S41, 0x655B59C3L) # 53
- d = XX(I, d, a, b, c, inp[ 3], S42, 0x8F0CCC92L) # 54
- c = XX(I, c, d, a, b, inp[10], S43, 0xFFEFF47DL) # 55
- b = XX(I, b, c, d, a, inp[ 1], S44, 0x85845DD1L) # 56
- a = XX(I, a, b, c, d, inp[ 8], S41, 0x6FA87E4FL) # 57
- d = XX(I, d, a, b, c, inp[15], S42, 0xFE2CE6E0L) # 58
- c = XX(I, c, d, a, b, inp[ 6], S43, 0xA3014314L) # 59
- b = XX(I, b, c, d, a, inp[13], S44, 0x4E0811A1L) # 60
- a = XX(I, a, b, c, d, inp[ 4], S41, 0xF7537E82L) # 61
- d = XX(I, d, a, b, c, inp[11], S42, 0xBD3AF235L) # 62
- c = XX(I, c, d, a, b, inp[ 2], S43, 0x2AD7D2BBL) # 63
- b = XX(I, b, c, d, a, inp[ 9], S44, 0xEB86D391L) # 64
+ a = XX(I, a, b, c, d, inp[ 0], S41, 0xF4292244) # 49
+ d = XX(I, d, a, b, c, inp[ 7], S42, 0x432AFF97) # 50
+ c = XX(I, c, d, a, b, inp[14], S43, 0xAB9423A7) # 51
+ b = XX(I, b, c, d, a, inp[ 5], S44, 0xFC93A039) # 52
+ a = XX(I, a, b, c, d, inp[12], S41, 0x655B59C3) # 53
+ d = XX(I, d, a, b, c, inp[ 3], S42, 0x8F0CCC92) # 54
+ c = XX(I, c, d, a, b, inp[10], S43, 0xFFEFF47D) # 55
+ b = XX(I, b, c, d, a, inp[ 1], S44, 0x85845DD1) # 56
+ a = XX(I, a, b, c, d, inp[ 8], S41, 0x6FA87E4F) # 57
+ d = XX(I, d, a, b, c, inp[15], S42, 0xFE2CE6E0) # 58
+ c = XX(I, c, d, a, b, inp[ 6], S43, 0xA3014314) # 59
+ b = XX(I, b, c, d, a, inp[13], S44, 0x4E0811A1) # 60
+ a = XX(I, a, b, c, d, inp[ 4], S41, 0xF7537E82) # 61
+ d = XX(I, d, a, b, c, inp[11], S42, 0xBD3AF235) # 62
+ c = XX(I, c, d, a, b, inp[ 2], S43, 0x2AD7D2BB) # 63
+ b = XX(I, b, c, d, a, inp[ 9], S44, 0xEB86D391) # 64
- A = (A + a) & 0xffffffffL
- B = (B + b) & 0xffffffffL
- C = (C + c) & 0xffffffffL
- D = (D + d) & 0xffffffffL
+ A = (A + a) & 0xffffffff
+ B = (B + b) & 0xffffffff
+ C = (C + c) & 0xffffffff
+ D = (D + d) & 0xffffffff
self.A, self.B, self.C, self.D = A, B, C, D
@@ -267,10 +267,10 @@
the hashed string.
"""
- leninBuf = long(len(inBuf))
+ leninBuf = len(inBuf)
# Compute number of bytes mod 64.
- index = (self.count[0] >> 3) & 0x3FL
+ index = (self.count[0] >> 3) & 0x3F
# Update number of bits.
self.count[0] = self.count[0] + (leninBuf << 3)
@@ -309,7 +309,7 @@
input = [] + self.input
count = [] + self.count
- index = (self.count[0] >> 3) & 0x3fL
+ index = (self.count[0] >> 3) & 0x3f
if index < 56:
padLen = 56 - index
diff --git a/lib_pypy/_pypy_wait.py b/lib_pypy/_pypy_wait.py
--- a/lib_pypy/_pypy_wait.py
+++ b/lib_pypy/_pypy_wait.py
@@ -1,6 +1,6 @@
+from resource import _struct_rusage, struct_rusage
from ctypes import CDLL, c_int, POINTER, byref
from ctypes.util import find_library
-from resource import _struct_rusage, struct_rusage
__all__ = ["wait3", "wait4"]
diff --git a/lib_pypy/grp.py b/lib_pypy/grp.py
--- a/lib_pypy/grp.py
+++ b/lib_pypy/grp.py
@@ -59,6 +59,12 @@
libc.getgrent.argtypes = []
libc.getgrent.restype = POINTER(GroupStruct)
+libc.setgrent.argtypes = []
+libc.setgrent.restype = None
+
+libc.endgrent.argtypes = []
+libc.endgrent.restype = None
+
def _group_from_gstruct(res):
i = 0
mem = []
diff --git a/lib_pypy/stackless.py b/lib_pypy/stackless.py
--- a/lib_pypy/stackless.py
+++ b/lib_pypy/stackless.py
@@ -433,16 +433,16 @@
def insert(self):
if self.blocked:
- raise RuntimeError, "You cannot run a blocked tasklet"
+ raise RuntimeError("You cannot run a blocked tasklet")
if not self.alive:
- raise RuntimeError, "You cannot run an unbound(dead) tasklet"
+ raise RuntimeError("You cannot run an unbound(dead) tasklet")
_scheduler_append(self)
def remove(self):
if self.blocked:
- raise RuntimeError, "You cannot remove a blocked tasklet."
+ raise RuntimeError("You cannot remove a blocked tasklet.")
if self is getcurrent():
- raise RuntimeError, "The current tasklet cannot be removed."
+ raise RuntimeError("The current tasklet cannot be removed.")
# not sure if I will revive this " Use t=tasklet().capture()"
_scheduler_remove(self)
More information about the pypy-commit
mailing list