diff options
author | Damien George <damien@micropython.org> | 2021-06-29 17:32:18 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2021-07-15 00:12:41 +1000 |
commit | e3825e28e61561427fd5811c1167e05ee3372eb4 (patch) | |
tree | 7de6451963ae4197464df5b77213d3dc639ef9e1 /tests/basics/subclass_native3.py | |
parent | b8255dd2e00f926106083de7a9b41869b226e96b (diff) | |
download | micropython-e3825e28e61561427fd5811c1167e05ee3372eb4.tar.gz micropython-e3825e28e61561427fd5811c1167e05ee3372eb4.zip |
py/objexcept: Make mp_obj_exception_get_value support subclassed excs.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/basics/subclass_native3.py')
-rw-r--r-- | tests/basics/subclass_native3.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/basics/subclass_native3.py b/tests/basics/subclass_native3.py index ac5aabfed7..0c45c4924f 100644 --- a/tests/basics/subclass_native3.py +++ b/tests/basics/subclass_native3.py @@ -34,6 +34,26 @@ print(MyStopIteration().value) print(MyStopIteration(1).value) +class Iter: + def __iter__(self): + return self + + def __next__(self): + # This exception will stop the "yield from", with a value of 3 + raise MyStopIteration(3) + + +def gen(): + print((yield from Iter())) + return 4 + + +try: + next(gen()) +except StopIteration as er: + print(er.args) + + class MyOSError(OSError): pass |