Commit 548e76cf authored by Damien George's avatar Damien George
Browse files

py: Use _is_subclass_fast instead of _exception_match.

parent 752ba554
...@@ -174,8 +174,9 @@ STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) { ...@@ -174,8 +174,9 @@ STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) {
} }
// Swallow StopIteration & GeneratorExit (== successful close), and re-raise any other // Swallow StopIteration & GeneratorExit (== successful close), and re-raise any other
if (ret_kind == MP_VM_RETURN_EXCEPTION) { if (ret_kind == MP_VM_RETURN_EXCEPTION) {
if (mp_obj_exception_match(ret, &mp_type_GeneratorExit) || // ret should always be an instance of an exception class
mp_obj_exception_match(ret, &mp_type_StopIteration)) { if (mp_obj_is_subclass_fast(mp_obj_get_type(ret), &mp_type_GeneratorExit) ||
mp_obj_is_subclass_fast(mp_obj_get_type(ret), &mp_type_StopIteration)) {
return mp_const_none; return mp_const_none;
} }
nlr_jump(ret); nlr_jump(ret);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment