QUERY · ISSUE
Implement exit() to exit for ./micropython shell
enhancementport-unix
I know that currently CTRL-D exits the shell.
For consistency with other python shells i.e CPython, let us implement exit() as an option to also exit the shell.
If this sounds good, i will track this for myself so that I can implement this as part of google season of docs.
CANDIDATE · ISSUE
Context manager __exit__() not called in generator which does not run to completion
proposed-close
This occurs when a generator does not run to completion e.g. one yielding an infinite set. The following works in cPython but not in MicroPython:
class foo(object):
def __enter__(self):
print('Enter')
def __exit__(self, *args):
print('Exit')
def bar(x):
with foo():
while True:
x += 1
yield x
def func():
g = bar(0)
for _ in range(3):
print(next(g))
func()
MicroPython:
[adminpete@axolotl]: ~
$ unix/upython
MicroPython v1.8.1-794-g29f3f84-dirty on 2016-11-10; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import rats10
Enter
1
2
3
>>>
cPython
$ python3
Python 3.4.3 (default, Sep 14 2016, 12:36:27)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import rats10
Enter
1
2
3
Exit
>>>
A similar effect can be seen in try...finally blocks. In cPython the finally block runs on exit from the REPL, in MicroPython never. In my view the context manager issue is the more serious one.