<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/objgenerator.c, branch 6.1.0</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=6.1.0</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=6.1.0'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2020-10-11T06:39:32+00:00</updated>
<entry>
<title>update async tests with less upython workaround and more cpython compatibility</title>
<updated>2020-10-11T06:39:32+00:00</updated>
<author>
<name>Kenny</name>
<email>3454741+WarriorOfWire@users.noreply.github.com</email>
</author>
<published>2020-10-11T06:39:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=98aa4b794346161e512d0fba913901021dd2cfbf'/>
<id>urn:sha1:98aa4b794346161e512d0fba913901021dd2cfbf</id>
<content type='text'>
</content>
</entry>
<entry>
<title>async def syntax rigor and __await__ magic method</title>
<updated>2020-10-10T22:45:08+00:00</updated>
<author>
<name>Kenny</name>
<email>3454741+WarriorOfWire@users.noreply.github.com</email>
</author>
<published>2020-08-06T02:55:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=bf849ff674a953ea36dbffc856a05158b2350077'/>
<id>urn:sha1:bf849ff674a953ea36dbffc856a05158b2350077</id>
<content type='text'>
Some examples of improved compliance with CPython that currently
have divergent behavior in CircuitPython are listed below:

* yield from is not allowed in async methods
```
&gt;&gt;&gt; async def f():
...     yield from 'abc'
...
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 2, in f
SyntaxError: 'yield from' inside async function
```

* await only works on awaitable expressions
```
&gt;&gt;&gt; async def f():
...     await 'not awaitable'
...
&gt;&gt;&gt; f().send(None)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "&lt;stdin&gt;", line 2, in f
AttributeError: 'str' object has no attribute '__await__'
```

* only __await__()able expressions are awaitable
Okay this one actually does not work in circuitpython at all today.
This is how CPython works though and pretending __await__ does not
exist will only bite users who write both.
```
&gt;&gt;&gt; class c:
...     pass
...
&gt;&gt;&gt; def f(self):
...     yield
...     yield
...     return 'f to pay respects'
...
&gt;&gt;&gt; c.__await__ = f  # could just as easily have put it on the class but this shows how it's wired
&gt;&gt;&gt; async def g():
...     awaitable_thing = c()
...     partial = await awaitable_thing
...     return 'press ' + partial
...
&gt;&gt;&gt; q = g()
&gt;&gt;&gt; q.send(None)
&gt;&gt;&gt; q.send(None)
&gt;&gt;&gt; q.send(None)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
StopIteration: press f to pay respects
```
</content>
</entry>
<entry>
<title>remove new char*s because m0 is way oversubscribed</title>
<updated>2020-07-24T03:41:10+00:00</updated>
<author>
<name>Kenny</name>
<email>3454741+WarriorOfWire@users.noreply.github.com</email>
</author>
<published>2020-07-22T05:34:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=e9b4e0bd35b6c3024a662580e547df62ab95acd1'/>
<id>urn:sha1:e9b4e0bd35b6c3024a662580e547df62ab95acd1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>add coroutine behavior for generators</title>
<updated>2020-07-24T03:40:16+00:00</updated>
<author>
<name>Kenny</name>
<email>3454741+WarriorOfWire@users.noreply.github.com</email>
</author>
<published>2020-07-21T07:01:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=51a79b1af7fa663bb078136611705c04df12970a'/>
<id>urn:sha1:51a79b1af7fa663bb078136611705c04df12970a</id>
<content type='text'>
coroutines don't have __next__; they also call themselves coroutines.
This does not change the fact that `async def` methods are generators,
but it does make them behave more like CPython.
</content>
</entry>
<entry>
<title>Add license to some obvious files.</title>
<updated>2020-07-06T18:16:25+00:00</updated>
<author>
<name>Diego Elio Pettenò</name>
<email>flameeyes@flameeyes.com</email>
</author>
<published>2020-06-03T22:40:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=34b4993d63a6b576f29d624385c681f679b4124c'/>
<id>urn:sha1:34b4993d63a6b576f29d624385c681f679b4124c</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>WIP: after merge; before testing</title>
<updated>2018-07-11T20:45:30+00:00</updated>
<author>
<name>Dan Halbert</name>
<email>halbert@halwitz.org</email>
</author>
<published>2018-07-11T20:45:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=7c219600a246d8956d0b23ea3f5d125a820e6b6a'/>
<id>urn:sha1:7c219600a246d8956d0b23ea3f5d125a820e6b6a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/objgenerator: Protect against reentering a generator.</title>
<updated>2018-05-22T06:54:03+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-05-22T06:54:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=400273a799581e5eb86538d8c88fb872705475ab'/>
<id>urn:sha1:400273a799581e5eb86538d8c88fb872705475ab</id>
<content type='text'>
Generators that are already executing cannot be reexecuted.  This patch
puts in a check for such a case.

Thanks to @jepler for finding the bug.
</content>
</entry>
<entry>
<title>py/objgenerator: Save state in old_globals instead of local variable.</title>
<updated>2018-05-22T06:39:19+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-05-22T06:39:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=771cb359af5242762baa29645c37cafa23c47b25'/>
<id>urn:sha1:771cb359af5242762baa29645c37cafa23c47b25</id>
<content type='text'>
The code_state.old_globals variable is there to save the globals state so
should be used for this purpose, to avoid the need for additional local
variables on the C stack.
</content>
</entry>
<entry>
<title>py/objgenerator: Check stack before resuming a generator.</title>
<updated>2018-04-10T04:06:26+00:00</updated>
<author>
<name>Jeff Epler</name>
<email>jepler@gmail.com</email>
</author>
<published>2018-04-01T17:15:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=cbf981f3307661c205d27f3a418be3989ab47c5e'/>
<id>urn:sha1:cbf981f3307661c205d27f3a418be3989ab47c5e</id>
<content type='text'>
This turns a hard crash in a recursive generator into a 'maximum recursion
depth exceeded' exception.
</content>
</entry>
</feed>
