From 22602cc37bc2454568cc9e8834a8ba444c85be05 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 1 Sep 2015 15:35:31 +0100 Subject: [PATCH] py/objstr: Make str.rsplit(None,n) raise NotImpl instead of assert(0). --- py/objstr.c | 2 +- tests/misc/non_compliant.py | 6 ++++++ tests/misc/non_compliant.py.exp | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/py/objstr.c b/py/objstr.c index 814dd9e132..f1e4e6b7bf 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -578,7 +578,7 @@ STATIC mp_obj_t str_rsplit(mp_uint_t n_args, const mp_obj_t *args) { mp_int_t idx = splits; if (sep == mp_const_none) { - assert(!"TODO: rsplit(None,n) not implemented"); + mp_not_implemented("rsplit(None,n)"); } else { mp_uint_t sep_len; const char *sep_str = mp_obj_str_get_data(sep, &sep_len); diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py index ee1dcf3416..79f1e70c88 100644 --- a/tests/misc/non_compliant.py +++ b/tests/misc/non_compliant.py @@ -39,3 +39,9 @@ try: print('{a[0]}'.format(a=[1, 2])) except NotImplementedError: print('NotImplementedError') + +# str.rsplit(None, n) not implemented +try: + 'a a a'.rsplit(None, 1) +except NotImplementedError: + print('NotImplementedError') diff --git a/tests/misc/non_compliant.py.exp b/tests/misc/non_compliant.py.exp index 731dd220b5..3790f4f346 100644 --- a/tests/misc/non_compliant.py.exp +++ b/tests/misc/non_compliant.py.exp @@ -4,3 +4,4 @@ True True TypeError, ValueError NotImplementedError +NotImplementedError