[pypy-commit] pypy py3k: buffer fixes for py3k unicode/bytes
pjenvey
noreply at buildbot.pypy.org
Wed Apr 30 01:12:03 CEST 2014
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r71075:7d6cb4c95b5e
Date: 2014-04-29 16:09 -0700
http://bitbucket.org/pypy/pypy/changeset/7d6cb4c95b5e/
Log: buffer fixes for py3k unicode/bytes
diff --git a/pypy/module/struct/interp_struct.py b/pypy/module/struct/interp_struct.py
--- a/pypy/module/struct/interp_struct.py
+++ b/pypy/module/struct/interp_struct.py
@@ -51,7 +51,7 @@
# XXX inefficient
@unwrap_spec(format=str, offset=int)
def pack_into(space, format, w_buf, offset, args_w):
- res = pack(space, format, args_w).str_w(space)
+ res = pack(space, format, args_w).bytes_w(space)
buf = space.writebuf_w(w_buf)
if offset < 0:
offset += buf.getlength()
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -436,7 +436,7 @@
@staticmethod
def _op_val(space, w_other):
try:
- return space.str_w(w_other)
+ return space.bytes_w(w_other)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
@@ -740,12 +740,12 @@
# String-like argument
try:
- string = space.bufferstr_new_w(w_source)
+ buf = space.buffer_w(w_source, space.BUF_FULL_RO)
except OperationError, e:
if not e.match(space, space.w_TypeError):
raise
else:
- return [c for c in string]
+ return [c for c in buf.as_str()]
if space.isinstance_w(w_source, space.w_unicode):
raise OperationError(
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -72,19 +72,6 @@
self._utf8 = identifier
return identifier
- def readbuf_w(self, space):
- from rpython.rlib.rstruct.unichar import pack_unichar, UNICODE_SIZE
- builder = StringBuilder(len(self._value) * UNICODE_SIZE)
- for unich in self._value:
- pack_unichar(unich, builder)
- return StringBuffer(builder.build())
-
- def writebuf_w(self, space):
- raise OperationError(space.w_TypeError, space.wrap(
- "cannot use unicode as modifiable buffer"))
-
- #charbuf_w = str_w # XXX:
-
def listview_unicode(w_self):
return _create_list_from_unicode(w_self._value)
More information about the pypy-commit
mailing list