diff --git a/py/objstr.c b/py/objstr.c index 274e76daaaeff6e98171a4562456281bc5987571..704fa07e1de54ca956f8912e7a2ff75bf397eb3e 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -699,7 +699,9 @@ STATIC mp_obj_t str_startswith(mp_uint_t n_args, const mp_obj_t *args) { STATIC mp_obj_t str_endswith(mp_uint_t n_args, const mp_obj_t *args) { GET_STR_DATA_LEN(args[0], str, str_len); GET_STR_DATA_LEN(args[1], suffix, suffix_len); - assert(n_args == 2); + if (n_args > 2) { + mp_not_implemented("start/end indices"); + } if (suffix_len > str_len) { return mp_const_false; diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py index 09abac238858a03800095b5ee7ca7f9a85f26004..de845790670dec6101250be7957f10e6d5957e07 100644 --- a/tests/misc/non_compliant.py +++ b/tests/misc/non_compliant.py @@ -52,6 +52,12 @@ try: except NotImplementedError: print('NotImplementedError') +# str.endswith(s, start) not implemented +try: + 'abc'.endswith('c', 1) +except NotImplementedError: + print('NotImplementedError') + # bytes(...) with keywords not implemented try: bytes('abc', encoding='utf8') diff --git a/tests/misc/non_compliant.py.exp b/tests/misc/non_compliant.py.exp index 9278034aa42e104b50bef4187f2fc3f1ed56544d..28b1470d7c580ec6327a22d72e63bbfd9b04993a 100644 --- a/tests/misc/non_compliant.py.exp +++ b/tests/misc/non_compliant.py.exp @@ -8,3 +8,4 @@ NotImplementedError NotImplementedError NotImplementedError NotImplementedError +NotImplementedError