<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openmano-mpy/tests/cpydiff, branch master</title>
<subtitle>MicroPython source and hardware configuration for OpenMano</subtitle>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/'/>
<entry>
<title>py/objexcept: Support errno attribute on OSError exceptions.</title>
<updated>2021-04-23T12:03:46+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2021-04-20T07:11:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=3c4bfd1dec28ffbefc6379dedeaa24feaa2ef373'/>
<id>3c4bfd1dec28ffbefc6379dedeaa24feaa2ef373</id>
<content type='text'>
This commit adds the errno attribute to exceptions, so code can retrieve
errno codes from an OSError using exc.errno.

The implementation here simply lets `errno` (and the existing `value`)
attributes work on any exception instance (they both alias args[0]).  This
is for efficiency and to keep code size down.  The pros and cons of this
are:

Pros:
- more compatible with CPython, less difference to document and learn
- OSError().errno will correctly return None, whereas the current way of
  doing it via OSError().args[0] will raise an IndexError
- it reduces code size on most bare-metal ports (because they already have
  the errno qstr)
- for Python code that uses exc.errno the generated bytecode is 2 bytes
  smaller and more efficient to execute (compared with exc.args[0]); so
  bytecode loaded to RAM saves 2 bytes RAM for each use of this attribute,
  and bytecode that is frozen saves 2 bytes flash/ROM for each use
- it's easier/shorter to type, and saves 2 bytes of space in .py files that
  use it (for each use)

Cons:
- increases code size by 4-8 bytes on minimal ports that don't already have
  the `errno` qstr
- all exceptions now have .errno and .value attributes (a cpydiff test is
  added to address this)

See also #2407.

Signed-off-by: Damien George &lt;damien@micropython.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit adds the errno attribute to exceptions, so code can retrieve
errno codes from an OSError using exc.errno.

The implementation here simply lets `errno` (and the existing `value`)
attributes work on any exception instance (they both alias args[0]).  This
is for efficiency and to keep code size down.  The pros and cons of this
are:

Pros:
- more compatible with CPython, less difference to document and learn
- OSError().errno will correctly return None, whereas the current way of
  doing it via OSError().args[0] will raise an IndexError
- it reduces code size on most bare-metal ports (because they already have
  the errno qstr)
- for Python code that uses exc.errno the generated bytecode is 2 bytes
  smaller and more efficient to execute (compared with exc.args[0]); so
  bytecode loaded to RAM saves 2 bytes RAM for each use of this attribute,
  and bytecode that is frozen saves 2 bytes flash/ROM for each use
- it's easier/shorter to type, and saves 2 bytes of space in .py files that
  use it (for each use)

Cons:
- increases code size by 4-8 bytes on minimal ports that don't already have
  the `errno` qstr
- all exceptions now have .errno and .value attributes (a cpydiff test is
  added to address this)

See also #2407.

Signed-off-by: Damien George &lt;damien@micropython.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tests/cpydiff: Add CPy diff test for assignment expression behaviour.</title>
<updated>2020-06-16T12:06:47+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2020-06-16T11:42:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=a3c89cf907a3c2b7235ea86e9a229335212b9020'/>
<id>a3c89cf907a3c2b7235ea86e9a229335212b9020</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>tests/cpydiff: Add cpydiff test for __all__ used in imported package.</title>
<updated>2020-05-02T07:41:04+00:00</updated>
<author>
<name>Jim Mussared</name>
</author>
<published>2020-04-28T03:43:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=309c19d39b8d7556ef60d8a7545978ba8f77ecfe'/>
<id>309c19d39b8d7556ef60d8a7545978ba8f77ecfe</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>tests: Format all Python code with black, except tests in basics subdir.</title>
<updated>2020-03-30T02:21:58+00:00</updated>
<author>
<name>David Lechner</name>
</author>
<published>2020-03-23T02:26:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=3dc324d3f1312e40d3a8ed87e7244966bb756f26'/>
<id>3dc324d3f1312e40d3a8ed87e7244966bb756f26</id>
<content type='text'>
This adds the Python files in the tests/ directory to be formatted with
./tools/codeformat.py.  The basics/ subdirectory is excluded for now so we
aren't changing too much at once.

In a few places `# fmt: off`/`# fmt: on` was used where the code had
special formatting for readability or where the test was actually testing
the specific formatting.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds the Python files in the tests/ directory to be formatted with
./tools/codeformat.py.  The basics/ subdirectory is excluded for now so we
aren't changing too much at once.

In a few places `# fmt: off`/`# fmt: on` was used where the code had
special formatting for readability or where the test was actually testing
the specific formatting.
</pre>
</div>
</content>
</entry>
<entry>
<title>tests: Move CPy diff test to real test now that subclass equality works.</title>
<updated>2020-02-04T07:25:34+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2020-02-04T07:25:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=69b415f7458c135375a6a37b77c5eb87b29ebb8d'/>
<id>69b415f7458c135375a6a37b77c5eb87b29ebb8d</id>
<content type='text'>
Testing for equality of subclassed strings now works, thanks to commit
3aab54bf434e7f025a91ea05052f1bac439fad8c
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Testing for equality of subclassed strings now works, thanks to commit
3aab54bf434e7f025a91ea05052f1bac439fad8c
</pre>
</div>
</content>
</entry>
<entry>
<title>tests/cpydiff: Add os module environ differences.</title>
<updated>2020-02-04T06:54:31+00:00</updated>
<author>
<name>David Lechner</name>
</author>
<published>2020-02-02T21:33:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=74106757ac4f78609f71083a6452ce5ba7edb3c2'/>
<id>74106757ac4f78609f71083a6452ce5ba7edb3c2</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>tests/cpydiff: Add CPy diff-test for using dict.keys() as a set.</title>
<updated>2020-01-06T12:26:00+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2020-01-06T12:26:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=4d528bbaa836b3d6ec0218ca7f7c92e1bf73704c'/>
<id>4d528bbaa836b3d6ec0218ca7f7c92e1bf73704c</id>
<content type='text'>
See issue #5493.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
See issue #5493.
</pre>
</div>
</content>
</entry>
<entry>
<title>tests/cpydiff: Fix typo in types_bytes_keywords.py doc comments.</title>
<updated>2019-10-21T12:25:09+00:00</updated>
<author>
<name>clach04</name>
</author>
<published>2019-10-21T01:22:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=ffd11486d426fa3b45946da72d274cd88be942d1'/>
<id>ffd11486d426fa3b45946da72d274cd88be942d1</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>tests/cpydiff: Add case for difference in behaviour of bytes.format().</title>
<updated>2018-09-26T05:31:10+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
</author>
<published>2018-09-22T00:13:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=8181ec04a45826ac33ea3247fbc36bef98236123'/>
<id>8181ec04a45826ac33ea3247fbc36bef98236123</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>tests/cpydiff: Remove types_int_tobytesfloat now that it doesn't fail.</title>
<updated>2018-05-08T07:05:32+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2018-05-08T07:05:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=2ada1124d42a85e056637fc10c0c2764ba96bdd6'/>
<id>2ada1124d42a85e056637fc10c0c2764ba96bdd6</id>
<content type='text'>
Commit e269cabe3ed8bed1b7181359febb686edbb748ae added a check that the
first argument to the to_bytes() method is an integer, and now uPy
follows CPython behaviour and raises a TypeError for this test.

Note: CPython checks the argument types before checking the number of
arguments, but uPy does it the other way around, so they give different
exception messages for this test, but still the same type, a TypeError.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commit e269cabe3ed8bed1b7181359febb686edbb748ae added a check that the
first argument to the to_bytes() method is an integer, and now uPy
follows CPython behaviour and raises a TypeError for this test.

Note: CPython checks the argument types before checking the number of
arguments, but uPy does it the other way around, so they give different
exception messages for this test, but still the same type, a TypeError.
</pre>
</div>
</content>
</entry>
</feed>
