summaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-10-07 13:31:59 +1100
committerDamien George <damien.p.george@gmail.com>2016-10-07 13:31:59 +1100
commit3a0a7717304cc34a4d6ef55f767666c918c185b5 (patch)
tree1fe4bf5605c62004fe24b6233c95ca02d870c37d /py/runtime.c
parent0363e1d7b5b80046b49b07d8fbb739315474b4b9 (diff)
py: Add mp_raise_OSError(errno) helper function.
This is an often used code pattern, and its use reduces code size of the core by about 100 bytes.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c
index c3e187d8a..003c9f8b4 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -1405,6 +1405,10 @@ NORETURN void mp_raise_TypeError(const char *msg) {
mp_raise_msg(&mp_type_TypeError, msg);
}
+NORETURN void mp_raise_OSError(int errno_) {
+ nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno_)));
+}
+
NORETURN void mp_not_implemented(const char *msg) {
mp_raise_msg(&mp_type_NotImplementedError, msg);
}