<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/tests/basics/struct_micropython.py, branch 6.2.x</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=6.2.x</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=6.2.x'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2020-09-12T19:07:23+00:00</updated>
<entry>
<title>modstruct: Improve compliance with python3</title>
<updated>2020-09-12T19:07:23+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2020-09-12T18:57:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=54d97251fe2dd4939652a186bf703885e654b4d1'/>
<id>urn:sha1:54d97251fe2dd4939652a186bf703885e654b4d1</id>
<content type='text'>
While checking whether we can enable -Wimplicit-fallthrough, I encountered
a diagnostic in mp_binary_set_val_array_from_int which led to discovering
the following bug:
```
&gt;&gt;&gt; struct.pack("xb", 3)
b'\x03\x03'
```
That is, the next value (3) was used as the value of a padding byte, while
standard Python always fills "x" bytes with zeros.  I initially thought
this had to do with the unintentional fallthrough, but it doesn't.
Instead, this code would relate to an array.array with a typecode of
padding ('x'), which is ALSO not desktop Python compliant:
```
&gt;&gt;&gt; array.array('x', (1, 2, 3))
array('x', [1, 0, 0])
```
Possibly this is dead code that used to be shared between struct-setting
and array-setting, but it no longer is.

I also discovered that the argument list length for struct.pack
and struct.pack_into were not checked, and that the length of binary data
passed to array.array was not checked to be a multiple of the element
size.

I have corrected all of these to conform more closely to standard Python
and revised some tests where necessary.  Some tests for micropython-specific
behavior that does not conform to standard Python and is not present
in CircuitPython was deleted outright.
</content>
</entry>
<entry>
<title>Conditionally compile out nonstandard array/struct typecodes</title>
<updated>2018-03-26T23:13:49+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@unpythonic.net</email>
</author>
<published>2018-03-26T23:13:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=355bf8b5538b4fe2f9f07b0d8fb2f4500c2f96c6'/>
<id>urn:sha1:355bf8b5538b4fe2f9f07b0d8fb2f4500c2f96c6</id>
<content type='text'>
.. defaulting to off for circuitpython-supported boards, on for others.

.. fixing up the tests that fail when it is turned off, so that they skip
instead of failing
</content>
</entry>
<entry>
<title>py/modstruct: In struct.pack, stop converting if there are no args left.</title>
<updated>2017-09-01T00:10:51+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-09-01T00:10:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=793d826d9df67c3f544505beda63ca36d8dfa1c4'/>
<id>urn:sha1:793d826d9df67c3f544505beda63ca36d8dfa1c4</id>
<content type='text'>
This patch makes a repeat counter behave the same as repeating the
typecode, when there are not enough args.  For example:
struct.pack('2I', 1) now behave the same as struct.pack('II', 1).
</content>
</entry>
<entry>
<title>tests/basics: Convert "sys.exit()" to "raise SystemExit".</title>
<updated>2017-06-10T17:03:01+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2017-06-10T17:03:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=a2803b74f48849cb3a11fb492fee891044ecc1f4'/>
<id>urn:sha1:a2803b74f48849cb3a11fb492fee891044ecc1f4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>tests/basics/struct_micropython: Add test for 'S' typecode in ustruct.</title>
<updated>2017-03-14T07:27:43+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-03-14T07:27:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=05fec17d9b126ee680095110fd520162669a6ce7'/>
<id>urn:sha1:05fec17d9b126ee680095110fd520162669a6ce7</id>
<content type='text'>
The 'S' typecode is a uPy extension so it should be grouped with the other
extension (namely 'O' typecode).  Testing 'S' needs uctypes which is an
extmod module and not always available, so this test is made optional and
will only be run on ports that have (u)struct and uctypes.  Otherwise it
will be silently skipped.
</content>
</entry>
<entry>
<title>tests/basics: Add tests to improve coverage of binary.c.</title>
<updated>2016-12-28T05:11:54+00:00</updated>
<author>
<name>Rami Ali</name>
<email>flowergrass@users.noreply.github.com</email>
</author>
<published>2016-12-28T04:29:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=65574f817a949fea2316c335da866c1b8d20f1fb'/>
<id>urn:sha1:65574f817a949fea2316c335da866c1b8d20f1fb</id>
<content type='text'>
</content>
</entry>
</feed>
