py: Use _is_subclass_fast instead of _exception_match.

This commit is contained in:
Damien George 2014-03-26 18:55:29 +00:00
parent 752ba554cc
commit 548e76cfd6

View File

@ -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);