Author: Armin Rigo <[email protected]>
Branch:
Changeset: r3227:edac34833b64
Date: 2019-02-21 15:10 +0100
http://bitbucket.org/cffi/cffi/changeset/edac34833b64/
Log: Issue #402
Fix bug in documentation
diff --git a/doc/source/ref.rst b/doc/source/ref.rst
--- a/doc/source/ref.rst
+++ b/doc/source/ref.rst
@@ -157,8 +157,9 @@
- use ``file.write()`` and ``file.readinto()`` with
such a buffer (for files opened in binary mode)
-- use ``ffi.buffer(mystruct[0])[:] = socket.recv(len(buffer))`` to read
- into a struct over a socket, rewriting the contents of mystruct[0]
+- overwrite the content of a struct: if ``p`` is a cdata pointing to
+ it, use ``ffi.buffer(p)[:] = newcontent``, where ``newcontent`` is
+ a bytes object (``str`` in Python 2).
Remember that like in C, you can use ``array + index`` to get the pointer
to the index'th item of an array. (In C you might more naturally write
@@ -175,7 +176,7 @@
- ``buf[:] = newstr``: change the original content (or ``buf[start:end]
= newstr``)
-- ``len(buf), buf[index], buf[index] = newchar``: access as a sequence
+- ``len(buf)``, ``buf[index]``, ``buf[index] = newchar``: access as a sequence
of characters.
The buffer object returned by ``ffi.buffer(cdata)`` keeps alive the
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit