Skip to content

Commit 22602cc

Browse files
committed
py/objstr: Make str.rsplit(None,n) raise NotImpl instead of assert(0).
1 parent 1b69354 commit 22602cc

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

py/objstr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ STATIC mp_obj_t str_rsplit(mp_uint_t n_args, const mp_obj_t *args) {
578578
mp_int_t idx = splits;
579579

580580
if (sep == mp_const_none) {
581-
assert(!"TODO: rsplit(None,n) not implemented");
581+
mp_not_implemented("rsplit(None,n)");
582582
} else {
583583
mp_uint_t sep_len;
584584
const char *sep_str = mp_obj_str_get_data(sep, &sep_len);

tests/misc/non_compliant.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,9 @@
3939
print('{a[0]}'.format(a=[1, 2]))
4040
except NotImplementedError:
4141
print('NotImplementedError')
42+
43+
# str.rsplit(None, n) not implemented
44+
try:
45+
'a a a'.rsplit(None, 1)
46+
except NotImplementedError:
47+
print('NotImplementedError')

tests/misc/non_compliant.py.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ True
44
True
55
TypeError, ValueError
66
NotImplementedError
7+
NotImplementedError

0 commit comments

Comments
 (0)