py/objstr: For str.endswith(s, start) raise NotImpl instead of assert.

This commit is contained in:
Damien George 2015-09-04 16:49:56 +01:00
parent 0b7a66ab97
commit 55b11e6d38
3 changed files with 10 additions and 1 deletions

View File

@ -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) { 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[0], str, str_len);
GET_STR_DATA_LEN(args[1], suffix, suffix_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) { if (suffix_len > str_len) {
return mp_const_false; return mp_const_false;

View File

@ -52,6 +52,12 @@ try:
except NotImplementedError: except NotImplementedError:
print('NotImplementedError') print('NotImplementedError')
# str.endswith(s, start) not implemented
try:
'abc'.endswith('c', 1)
except NotImplementedError:
print('NotImplementedError')
# bytes(...) with keywords not implemented # bytes(...) with keywords not implemented
try: try:
bytes('abc', encoding='utf8') bytes('abc', encoding='utf8')

View File

@ -8,3 +8,4 @@ NotImplementedError
NotImplementedError NotImplementedError
NotImplementedError NotImplementedError
NotImplementedError NotImplementedError
NotImplementedError