Author: Richard Plangger <[email protected]>
Branch: strbuf-as-buffer
Changeset: r89327:a22f7d7e919f
Date: 2017-01-03 09:51 +0100
http://bitbucket.org/pypy/pypy/changeset/a22f7d7e919f/

Log:    added comments and remove typo, update error message

diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -88,9 +88,12 @@
         if isinstance(obj, (str, unicode)):
             # hack, buffer(str) will always return a readonly buffer.
             # CPython calls PyObject_AsWriteBuffer(...) here!
-            # str cannot be modified, thus rase a type error in this case
+            # str cannot be modified, thus raise a type error in this case
             raise TypeError("Cannot use %s as modifiable buffer" % 
str(type(obj)))
 
+        # why not just call memoryview(obj)[offset:]?
+        # array in Python 2.7 does not support the buffer protocol and will
+        # fail, even though buffer is supported
         buf = buffer(obj, offset, size)
 
         if len(buf) < size:
diff --git a/pypy/module/_cffi_backend/func.py 
b/pypy/module/_cffi_backend/func.py
--- a/pypy/module/_cffi_backend/func.py
+++ b/pypy/module/_cffi_backend/func.py
@@ -143,8 +143,7 @@
 def _from_buffer(space, w_ctype, w_x):
     if invalid_input_buffer_type(space, w_x):
         raise oefmt(space.w_TypeError,
-                        "from_buffer() cannot return the address of the "
-                        "raw string within a str or unicode object")
+                        "from_buffer() cannot return the address a unicode")
     buf = _fetch_as_read_buffer(space, w_x)
     if space.isinstance_w(w_x, space.w_str):
         _cdata = get_raw_address_of_string(space, w_x)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to