Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Making str.endwith respond correctly to tuples
  • Loading branch information
kellrott committed Jun 28, 2019
commit 8a52f448dc8ecd6388cb1fa95aa40063f524c8cf
6 changes: 6 additions & 0 deletions py/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ func init() {
if len(args) > 0 {
if s, ok := args[0].(String); ok {
suffix = append(suffix, string(s))
} else if s, ok := args[0].(Tuple); ok {
for _, t := range s {
if v, ok := t.(String); ok {
suffix = append(suffix, string(v))
}
}
} else {
return nil, ExceptionNewf(TypeError, "endswith first arg must be str, unicode, or tuple, not %s", args[0].Type())
}
Expand Down
1 change: 1 addition & 0 deletions py/tests/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class C():
doc="endswith"
assert "HELLO THERE".endswith("HERE")
assert not "HELLO THERE".endswith("HELL")
assert "HELLO THERE".endswith(("HELL", "HERE"))

doc="bool"
assert "true"
Expand Down