Skip to content

Commit 099a9cb

Browse files
committed
Remove mp_obj_new_exception_msg_1_arg and _2_arg.
1 parent 780ba22 commit 099a9cb

16 files changed

Lines changed: 30 additions & 41 deletions

py/obj.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag);
215215
#endif
216216
mp_obj_t mp_obj_new_exception(qstr id);
217217
mp_obj_t mp_obj_new_exception_msg(qstr id, const char *msg);
218-
mp_obj_t mp_obj_new_exception_msg_1_arg(qstr id, const char *fmt, const char *a1);
219-
mp_obj_t mp_obj_new_exception_msg_2_args(qstr id, const char *fmt, const char *a1, const char *a2);
220218
mp_obj_t mp_obj_new_exception_msg_varg(qstr id, const char *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!)
221219
mp_obj_t mp_obj_new_range(int start, int stop, int step);
222220
mp_obj_t mp_obj_new_range_iterator(int cur, int stop, int step);

py/objcomplex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ STATIC mp_obj_t complex_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
6666
}
6767

6868
default:
69-
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "complex takes at most 2 arguments, %d given", (void*)(machine_int_t)n_args));
69+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "complex takes at most 2 arguments, %d given", n_args));
7070
}
7171
}
7272

py/objexcept.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ STATIC mp_obj_t exception_call(mp_obj_t self_in, uint n_args, uint n_kw, const m
4848
mp_obj_exception_t *base = self_in;
4949

5050
if (n_kw != 0) {
51-
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "%s does not take keyword arguments", qstr_str(base->id)));
51+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "%s does not take keyword arguments", qstr_str(base->id)));
5252
}
5353

5454
mp_obj_exception_t *o = m_new_obj_var(mp_obj_exception_t, mp_obj_t, n_args);
@@ -75,14 +75,6 @@ mp_obj_t mp_obj_new_exception_msg(qstr id, const char *msg) {
7575
return mp_obj_new_exception_msg_varg(id, msg);
7676
}
7777

78-
mp_obj_t mp_obj_new_exception_msg_1_arg(qstr id, const char *fmt, const char *a1) {
79-
return mp_obj_new_exception_msg_varg(id, fmt, a1);
80-
}
81-
82-
mp_obj_t mp_obj_new_exception_msg_2_args(qstr id, const char *fmt, const char *a1, const char *a2) {
83-
return mp_obj_new_exception_msg_varg(id, fmt, a1, a2);
84-
}
85-
8678
mp_obj_t mp_obj_new_exception_msg_varg(qstr id, const char *fmt, ...) {
8779
// make exception object
8880
mp_obj_exception_t *o = m_new_obj_var(mp_obj_exception_t, mp_obj_t*, 0);

py/objfloat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ STATIC mp_obj_t float_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
4040
}
4141

4242
default:
43-
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "float takes at most 1 argument, %d given", (void*)(machine_int_t)n_args));
43+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "float takes at most 1 argument, %d given", n_args));
4444
}
4545
}
4646

py/objfun.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,19 @@ STATIC void check_nargs(mp_obj_fun_native_t *self, int n_args, int n_kw) {
2626

2727
if (self->n_args_min == self->n_args_max) {
2828
if (n_args != self->n_args_min) {
29-
nlr_jump(mp_obj_new_exception_msg_2_args(MP_QSTR_TypeError,
29+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError,
3030
"function takes %d positional arguments but %d were given",
31-
(const char*)(machine_int_t)self->n_args_min,
32-
(const char*)(machine_int_t)n_args));
31+
self->n_args_min, n_args));
3332
}
3433
} else {
3534
if (n_args < self->n_args_min) {
36-
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError,
35+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError,
3736
"<fun name>() missing %d required positional arguments: <list of names of params>",
38-
(const char*)(machine_int_t)(self->n_args_min - n_args)));
37+
self->n_args_min - n_args));
3938
} else if (n_args > self->n_args_max) {
40-
nlr_jump(mp_obj_new_exception_msg_2_args(MP_QSTR_TypeError,
39+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError,
4140
"<fun name> expected at most %d arguments, got %d",
42-
(void*)(machine_int_t)self->n_args_max, (void*)(machine_int_t)n_args));
41+
self->n_args_max, n_args));
4342
}
4443
}
4544
}
@@ -144,7 +143,7 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_o
144143
mp_obj_fun_bc_t *self = self_in;
145144

146145
if (n_args < self->n_args - self->n_def_args || n_args > self->n_args) {
147-
nlr_jump(mp_obj_new_exception_msg_2_args(MP_QSTR_TypeError, "function takes %d positional arguments but %d were given", (const char*)(machine_int_t)self->n_args, (const char*)(machine_int_t)n_args));
146+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "function takes %d positional arguments but %d were given", self->n_args, n_args));
148147
}
149148
if (n_kw != 0) {
150149
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "function does not take keyword arguments"));
@@ -253,7 +252,7 @@ STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_
253252
mp_obj_fun_asm_t *self = self_in;
254253

255254
if (n_args != self->n_args) {
256-
nlr_jump(mp_obj_new_exception_msg_2_args(MP_QSTR_TypeError, "function takes %d positional arguments but %d were given", (const char*)(machine_int_t)self->n_args, (const char*)(machine_int_t)n_args));
255+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "function takes %d positional arguments but %d were given", self->n_args, n_args));
257256
}
258257
if (n_kw != 0) {
259258
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "function does not take keyword arguments"));

py/objgenerator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp
2828
const byte *bc_code;
2929
mp_obj_fun_bc_get(self_fun, &bc_n_args, &bc_n_state, &bc_code);
3030
if (n_args != bc_n_args) {
31-
nlr_jump(mp_obj_new_exception_msg_2_args(MP_QSTR_TypeError, "function takes %d positional arguments but %d were given", (const char*)(machine_int_t)bc_n_args, (const char*)(machine_int_t)n_args));
31+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "function takes %d positional arguments but %d were given", bc_n_args, n_args));
3232
}
3333
if (n_kw != 0) {
3434
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "function does not take keyword arguments"));

py/objint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ STATIC mp_obj_t int_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
3939
}
4040

4141
default:
42-
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "int takes at most 2 arguments, %d given", (void*)(machine_int_t)n_args));
42+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "int takes at most 2 arguments, %d given", n_args));
4343
}
4444
}
4545

py/objlist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ STATIC mp_obj_t list_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
6262
}
6363

6464
default:
65-
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "list takes at most 1 argument, %d given", (void*)(machine_int_t)n_args));
65+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "list takes at most 1 argument, %d given", n_args));
6666
}
6767
return NULL;
6868
}

py/objset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ STATIC mp_obj_t set_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
6767
}
6868

6969
default:
70-
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "set takes at most 1 argument, %d given", (void*)(machine_int_t)n_args));
70+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "set takes at most 1 argument, %d given", n_args));
7171
}
7272
}
7373

py/objtuple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ STATIC mp_obj_t tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
7070
}
7171

7272
default:
73-
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "tuple takes at most 1 argument, %d given", (void*)(machine_int_t)n_args));
73+
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "tuple takes at most 1 argument, %d given", n_args));
7474
}
7575
}
7676

0 commit comments

Comments
 (0)