mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user