diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-08-29 00:06:21 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-08-29 00:06:21 +0300 |
commit | 37379a2974190ab0fc97f840112d5a40c907368b (patch) | |
tree | 7c4d0ce9e82aa58ca8af5198a57f1e3211fb7a82 /tests/basics/string_startswith_upy.py | |
parent | c5c095690fc8294068e88c71baca92bf757ad91c (diff) | |
download | micropython-37379a2974190ab0fc97f840112d5a40c907368b.tar.gz micropython-37379a2974190ab0fc97f840112d5a40c907368b.zip |
py/objstr: startswith, endswith: Check arg to be a string.
Otherwise, it will silently get incorrect result on other values types,
including CPython tuple form like "foo.png".endswith(("png", "jpg"))
(which MicroPython doesn't support for unbloatedness).
Diffstat (limited to 'tests/basics/string_startswith_upy.py')
-rw-r--r-- | tests/basics/string_startswith_upy.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/basics/string_startswith_upy.py b/tests/basics/string_startswith_upy.py new file mode 100644 index 0000000000..9ea1796c21 --- /dev/null +++ b/tests/basics/string_startswith_upy.py @@ -0,0 +1,6 @@ +# MicroPython doesn't support tuple argument + +try: + "foobar".startswith(("foo", "sth")) +except TypeError: + print("TypeError") |