summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/subclass_native3.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-06-29 17:32:18 +1000
committerDamien George <damien@micropython.org>2021-07-15 00:12:41 +1000
commite3825e28e61561427fd5811c1167e05ee3372eb4 (patch)
tree7de6451963ae4197464df5b77213d3dc639ef9e1 /tests/basics/subclass_native3.py
parentb8255dd2e00f926106083de7a9b41869b226e96b (diff)
downloadmicropython-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.py20
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