[pypy-commit] pypy py3.5-ssl: structural changes to fix translation, triggered by union error
plan_rich
pypy.commits at gmail.com
Wed Dec 7 06:30:23 EST 2016
Author: Richard Plangger <planrichi at gmail.com>
Branch: py3.5-ssl
Changeset: r88933:f40c39b6dcf1
Date: 2016-12-07 12:29 +0100
http://bitbucket.org/pypy/pypy/changeset/f40c39b6dcf1/
Log: structural changes to fix translation, triggered by union error
diff --git a/pypy/objspace/std/memoryobject.py b/pypy/objspace/std/memoryobject.py
--- a/pypy/objspace/std/memoryobject.py
+++ b/pypy/objspace/std/memoryobject.py
@@ -220,13 +220,13 @@
while dim < length:
w_obj = w_tuple.getitem(space, dim)
index = space.getindex_w(w_obj, space.w_IndexError)
- start = self.lookup_dimension(space, self.buf, start, dim, index)
+ shape = self.buf.getshape()
+ strides = self.buf.getstrides()
+ start = self.lookup_dimension(space, shape, strides, start, dim, index)
dim += 1
return start
- def lookup_dimension(self, space, view, start, dim, index):
- shape = view.getshape()
- strides = view.getstrides()
+ def lookup_dimension(self, space, shape, strides, start, dim, index):
nitems = shape[dim]
if index < 0:
index += nitems
@@ -281,7 +281,9 @@
if dim == 0:
raise oefmt(space.w_TypeError, "invalid indexing of 0-dim memory")
elif dim == 1:
- idx = self.lookup_dimension(space, self, 0, 0, start)
+ shape = self.getshape()
+ strides = self.getstrides()
+ idx = self.lookup_dimension(space, shape, strides, 0, 0, start)
if itemsize == 1:
ch = self.buf.getitem(idx)
return space.newint(ord(ch))
@@ -326,10 +328,9 @@
return length * self.getitemsize()
@staticmethod
- def copy(view, buf=None):
+ def copy(view):
# TODO suboffsets
- if buf == None:
- buf = view.buf
+ buf = view.buf
return W_MemoryView(buf, view.getformat(), view.getitemsize(),
view.getndim(), view.getshape()[:], view.getstrides()[:])
@@ -344,9 +345,12 @@
start, stop, step, slicelength = self._decode_index(space, w_index, is_slice)
itemsize = self.getitemsize()
if step == 0: # index only
+ shape = self.getshape()
+ strides = self.getstrides()
+ idx = self.lookup_dimension(space, shape, strides, 0, 0, start)
if itemsize == 1:
ch = getbytevalue(space, w_obj)
- self.buf.setitem(start, ch)
+ self.buf.setitem(idx, ch)
else:
# TODO: this probably isn't very fast
fmtiter = PackFormatIterator(space, [w_obj], itemsize)
@@ -356,7 +360,7 @@
raise oefmt(space.w_TypeError,
"memoryview: invalid type for format '%s'",
self.format)
- self.buf.setslice(start * itemsize, fmtiter.result.build())
+ self.buf.setslice(idx, fmtiter.result.build())
elif step == 1:
value = space.buffer_w(w_obj, space.BUF_CONTIG_RO)
if value.getlength() != slicelength * itemsize:
More information about the pypy-commit
mailing list