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).
This commit is contained in:
Paul Sokolovsky
2017-08-29 00:06:21 +03:00
parent c5c095690f
commit 37379a2974
7 changed files with 28 additions and 2 deletions

View File

@@ -9,3 +9,8 @@ print("1foo".startswith("foo", 1))
print("1foo".startswith("1foo", 1))
print("1fo".startswith("foo", 1))
print("1fo".startswith("foo", 10))
try:
"foobar".startswith(1)
except TypeError:
print("TypeError")