<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/objstringio.c, branch master</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=master</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2019-12-04T15:29:57+00:00</updated>
<entry>
<title>protocols: Allow them to be (optionally) type-safe</title>
<updated>2019-12-04T15:29:57+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2019-12-03T20:50:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=238e12123690debaf2cf8488fb2a4d4003a06506'/>
<id>urn:sha1:238e12123690debaf2cf8488fb2a4d4003a06506</id>
<content type='text'>
Protocols are nice, but there is no way for C code to verify whether
a type's "protocol" structure actually implements some particular
protocol.  As a result, you can pass an object that implements the
"vfs" protocol to one that expects the "stream" protocol, and the
opposite of awesomeness ensues.

This patch adds an OPTIONAL (but enabled by default) protocol identifier
as the first member of any protocol structure.  This identifier is
simply a unique QSTR chosen by the protocol designer and used by each
protocol implementer.  When checking for protocol support, instead of
just checking whether the object's type has a non-NULL protocol field,
use `mp_proto_get` which implements the protocol check when possible.

The existing protocols are now named:
    protocol_framebuf
    protocol_i2c
    protocol_pin
    protocol_stream
    protocol_spi
    protocol_vfs
(most of these are unused in CP and are just inherited from MP; vfs and
stream are definitely used though)

I did not find any crashing examples, but here's one to give a flavor of what
is improved, using `micropython_coverage`.  Before the change,
the vfs "ioctl" protocol is invoked, and the result is not intelligible
as json (but it could have resulted in a hard fault, potentially):

    &gt;&gt;&gt; import uos, ujson
    &gt;&gt;&gt; u = uos.VfsPosix('/tmp')
    &gt;&gt;&gt; ujson.load(u)
    Traceback (most recent call last):
      File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    ValueError: syntax error in JSON

After the change, the vfs object is correctly detected as not supporting
the stream protocol:
    &gt;&gt;&gt; ujson.load(p)
    Traceback (most recent call last):
      File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    OSError: stream operation not supported
</content>
</entry>
<entry>
<title>py changes for supporting superclass constructors that take kwargs</title>
<updated>2019-01-15T01:29:19+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott@tannewt.org</email>
</author>
<published>2019-01-14T23:14:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=72d993d60c5e5238942491df00776ca31f9758a1'/>
<id>urn:sha1:72d993d60c5e5238942491df00776ca31f9758a1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Two fixes and translate more strings.</title>
<updated>2018-08-09T20:29:30+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott@tannewt.org</email>
</author>
<published>2018-08-09T01:24:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=96ebf5bc3fb455162286b9bc31e763f3c4f1c457'/>
<id>urn:sha1:96ebf5bc3fb455162286b9bc31e763f3c4f1c457</id>
<content type='text'>
* Fix finding translations with escaped characters.
* Add back \r to translations since its needed by screen.
</content>
</entry>
<entry>
<title>py/stream: Switch stream close operation from method to ioctl.</title>
<updated>2018-04-10T03:41:32+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-03-07T06:48:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=cf31d384f1d2ca09f817f154892eaa6860c10144'/>
<id>urn:sha1:cf31d384f1d2ca09f817f154892eaa6860c10144</id>
<content type='text'>
This patch moves the implementation of stream closure from a dedicated
method to the ioctl of the stream protocol, for each type that implements
closing.  The benefits of this are:

1. Rounds out the stream ioctl function, which already includes flush,
   seek and poll (among other things).

2. Makes calling mp_stream_close() on an object slightly more efficient
   because it now no longer needs to lookup the close method and call it,
   rather it just delegates straight to the ioctl function (if it exists).

3. Reduces code size and allows future types that implement the stream
   protocol to be smaller because they don't need a dedicated close method.

Code size reduction is around 200 bytes smaller for x86 archs and around
30 bytes smaller for the bare-metal archs.
</content>
</entry>
<entry>
<title>all: Remove inclusion of internal py header files.</title>
<updated>2017-10-04T01:37:50+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-10-04T01:37:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=a3dc1b1957d2c96d7c60c2c629c95077b03488a1'/>
<id>urn:sha1:a3dc1b1957d2c96d7c60c2c629c95077b03488a1</id>
<content type='text'>
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
</content>
</entry>
<entry>
<title>py/objstringio: Fix regression with handling SEEK_SET.</title>
<updated>2017-08-20T19:02:41+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2017-08-20T18:32:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=0cd9ab77550eada4def492a3a25286ead71a3b24'/>
<id>urn:sha1:0cd9ab77550eada4def492a3a25286ead71a3b24</id>
<content type='text'>
For SEEK_SET, offset should be treated as unsigned, to allow full-width
stream sizes (e.g. 32-bit instead of 31-bit). This is now fully documented
in stream.h. Also, seek symbolic constants are added.
</content>
</entry>
<entry>
<title>py/objstringio: Prevent offset wraparound for io.BytesIO objects.</title>
<updated>2017-08-20T19:00:05+00:00</updated>
<author>
<name>Tom Collins</name>
<email>tom.collins@digi.com</email>
</author>
<published>2017-05-25T20:53:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=168350cd9849b0ab56867c487cfd78ca68c2b228'/>
<id>urn:sha1:168350cd9849b0ab56867c487cfd78ca68c2b228</id>
<content type='text'>
Too big positive, or too big negative offset values could lead to overflow
and address space wraparound and thus access to unrelated areas of memory
(a security issue).
</content>
</entry>
<entry>
<title>all: Use the name MicroPython consistently in comments</title>
<updated>2017-07-31T08:35:40+00:00</updated>
<author>
<name>Alexander Steffen</name>
<email>devel.20.webmeister@spamgourmet.com</email>
</author>
<published>2017-06-30T07:22:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=55f33240f3d7051d4213629e92437a36f1fac50e'/>
<id>urn:sha1:55f33240f3d7051d4213629e92437a36f1fac50e</id>
<content type='text'>
There were several different spellings of MicroPython present in comments,
when there should be only one.
</content>
</entry>
<entry>
<title>py/objstringio: If created from immutable object, follow copy on write policy.</title>
<updated>2017-06-09T14:33:01+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2017-06-05T20:54:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=07241cd37a732e4219257e6b2fc67a84085b37f6'/>
<id>urn:sha1:07241cd37a732e4219257e6b2fc67a84085b37f6</id>
<content type='text'>
Don't create copy of immutable object's contents until .write() is called
on BytesIO.
</content>
</entry>
<entry>
<title>py/objstringio: Catch mp_uint_t overflow of stream position in write().</title>
<updated>2017-05-26T03:40:08+00:00</updated>
<author>
<name>Tom Collins</name>
<email>tom.collins@digi.com</email>
</author>
<published>2017-05-25T20:41:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=e26fb3ad73d1c663f9e6aee45306ce86f8342e1e'/>
<id>urn:sha1:e26fb3ad73d1c663f9e6aee45306ce86f8342e1e</id>
<content type='text'>
</content>
</entry>
</feed>
