Commit 238226d1 authored by Matti Picus's avatar Matti Picus
Browse files

merge default into branch

--HG--
branch : py3.7
Pipeline #21696 passed with stage
in 8 minutes and 48 seconds
......@@ -109,3 +109,5 @@ db1e853f94de42ad711bd930222bd2434e0f900d release-pypy3.6-v7.3.3
51efa818fd9b24f625078c65e8e2f6a5ac24d572 release-pypy3.7-v7.3.4
e02eba563ef8ad7b5097acd72a81ae1f8ddda796 release-pypy2.7-v7.3.5rc1
d770377ff27b810daef22c770e669ec9542363fe release-pypy3.7-v7.3.5rc1
cc3e122f7896d959fe0d21eb74bab75085c48fdb release-pypy2.7-v7.3.5rc2
cd00c77c619f02c43c23e6a2514e5b685230ef02 release-pypy3.7-v7.3.5rc2
......@@ -369,7 +369,7 @@ def PyObject_Hash(space, w_obj):
This is the equivalent of the Python expression hash(o)."""
return space.hash_w(w_obj)
@cpython_api([rffi.DOUBLE], rffi.LONG, error=-1)
@cpython_api([rffi.DOUBLE], lltype.Signed, error=-1)
def _Py_HashDouble(space, v):
return space.hash_w(space.newfloat(v))
......
......@@ -660,10 +660,9 @@ class BufferingInputStream(Stream):
def readall(self):
pos = self.pos
assert pos >= 0
builder = StringBuilder()
if self.buf:
chunks = [self.buf[pos:]]
else:
chunks = []
builder.append_slice(self.buf, pos, len(self.buf))
self.buf = ""
self.pos = 0
bufsize = self.bufsize
......@@ -673,14 +672,14 @@ class BufferingInputStream(Stream):
except OSError as o:
# like CPython < 3.4, partial results followed by an error
# are returned as data
if not chunks:
if not builder.getlength():
raise
break
if not data:
break
chunks.append(data)
builder.append(data)
bufsize = min(bufsize*2, self.bigsize)
return "".join(chunks)
return builder.build()
def read(self, n=-1):
assert isinstance(n, int)
......@@ -696,7 +695,8 @@ class BufferingInputStream(Stream):
self.pos += n
return result
else:
chunks = [self.buf[start:]]
builder = StringBuilder(n)
builder.append_slice(self.buf, start, len(self.buf))
while 1:
self.buf = self.do_read(self.bufsize)
if not self.buf:
......@@ -707,12 +707,12 @@ class BufferingInputStream(Stream):
self.pos = len(self.buf) - (currentsize - n)
stop = self.pos
assert stop >= 0
chunks.append(self.buf[:stop])
builder.append_slice(self.buf, 0, stop)
break
buf = self.buf
assert buf is not None
chunks.append(buf)
return ''.join(chunks)
builder.append(buf)
return builder.build()
def readline(self):
pos = self.pos
......@@ -738,7 +738,9 @@ class BufferingInputStream(Stream):
self.pos = 0
return temp
# need to keep getting data until we find a new line
chunks = [temp, self.buf]
builder = StringBuilder(len(temp) + len(self.buf)) # at least
builder.append(temp)
builder.append(self.buf)
while 1:
self.buf = self.do_read(self.bufsize)
if not self.buf:
......@@ -747,11 +749,11 @@ class BufferingInputStream(Stream):
i = self.buf.find("\n")
if i >= 0:
i += 1
chunks.append(self.buf[:i])
builder.append_slice(self.buf, 0, i)
self.pos = i
break
chunks.append(self.buf)
return "".join(chunks)
builder.append(self.buf)
return builder.build()
def peek(self):
return (self.pos, self.buf)
......
......@@ -1029,19 +1029,19 @@ class LLHelpers(AbstractLLHelpers):
strlen = len(chars)
i = 0
#XXX: only space is allowed as white space for now
while i < strlen and chars[i] == ' ':
while i < strlen and ord(chars[i]) == ord(' '):
i += 1
if not i < strlen:
raise ValueError
#check sign
sign = 1
if chars[i] == '-':
if ord(chars[i]) == ord('-'):
sign = -1
i += 1
elif chars[i] == '+':
elif ord(chars[i]) == ord('+'):
i += 1
# skip whitespaces between sign and digits
while i < strlen and chars[i] == ' ':
while i < strlen and ord(chars[i]) == ord(' '):
i += 1
#now get digits
val = 0
......@@ -1063,7 +1063,7 @@ class LLHelpers(AbstractLLHelpers):
if i == oldpos:
raise ValueError # catch strings like '+' and '+ '
#skip trailing whitespace
while i < strlen and chars[i] == ' ':
while i < strlen and ord(chars[i]) == ord(' '):
i += 1
if not i == strlen:
raise ValueError
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment