summaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2020-02-04 16:19:40 -0500
committerDan Halbert <halbert@halwitz.org>2020-02-04 16:19:40 -0500
commit5164719e67878418cff51d26f40e4813da02bc83 (patch)
tree61ce839ea0b9364d05604fc9cad948bfb082c9f6 /py/runtime.c
parent57b566e73614c74a9fc74cd2d2007d91cdb507db (diff)
preserve errno in OSError
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/py/runtime.c b/py/runtime.c
index cb174837c..c1c311ae4 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -1578,11 +1578,12 @@ NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg) {
mp_raise_msg(&mp_type_OSError, msg);
}
-NORETURN void mp_raise_OSError_errno_str(int errno_, const char *str) {
- char decompressed[50];
- const char *errno_str = mp_common_errno_to_str(MP_OBJ_NEW_SMALL_INT(errno_),
- decompressed, sizeof(decompressed));
- mp_raise_OSError_msg_varg(translate("[Errno %d] %s: %s"), errno_, errno_str, str);
+NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str) {
+ mp_obj_t args[2] = {
+ MP_OBJ_NEW_SMALL_INT(errno_),
+ str,
+ };
+ nlr_raise(mp_obj_new_exception_args(&mp_type_OSError, 2, args));
}
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...) {