summaryrefslogtreecommitdiff
path: root/py/objnamedtuple.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/objnamedtuple.c')
-rw-r--r--py/objnamedtuple.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c
index 84dcf7909..8b595da57 100644
--- a/py/objnamedtuple.c
+++ b/py/objnamedtuple.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -46,7 +46,7 @@ size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr n
return (size_t)-1;
}
-#if MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
+#if MICROPY_PY_COLLECTIONS_ORDEREDDICT
STATIC mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in);
const qstr *fields = ((mp_obj_namedtuple_type_t*)self->tuple.base.type)->fields;
@@ -102,17 +102,17 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const
n_kw = kw_args->used;
}
if (n_args + n_kw != num_fields) {
- if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
+ #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
mp_arg_error_terse_mismatch();
- } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL) {
+ #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL
mp_raise_TypeError_varg(
translate("function takes %d positional arguments but %d were given"),
num_fields, n_args + n_kw);
- } else if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED) {
+ #else
mp_raise_TypeError_varg(
translate("%q() takes %d positional arguments but %d were given"),
type->base.name, num_fields, n_args + n_kw);
- }
+ #endif
}
// Create a tuple and set the type to this namedtuple
@@ -128,20 +128,20 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const
qstr kw = mp_obj_str_get_qstr(kw_args->table[i].key);
size_t id = mp_obj_namedtuple_find_field(type, kw);
if (id == (size_t)-1) {
- if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
+ #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
mp_arg_error_terse_mismatch();
- } else {
+ #else
mp_raise_TypeError_varg(
translate("unexpected keyword argument '%q'"), kw);
- }
+ #endif
}
if (tuple->items[id] != MP_OBJ_NULL) {
- if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
+ #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
mp_arg_error_terse_mismatch();
- } else {
+ #else
mp_raise_TypeError_varg(
translate("function got multiple values for argument '%q'"), kw);
- }
+ #endif
}
tuple->items[id] = kw_args->table[i].value;
}