Skip to content

Commit

Permalink
Merge pull request #2484 from advikkabra/isalpha-fix
Browse files Browse the repository at this point in the history
Fixes empty string bug in str isalpha method
  • Loading branch information
certik authored Feb 7, 2024
2 parents a6b9256 + 08e1f45 commit 20b93b4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions integration_tests/test_str_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ def test_str_isalpha():
b: str = "hj kl"
c: str = "a12(){}A"
d: str = " "
e: str = ""
res: bool = a.isalpha()
res2: bool = b.isalpha()
res3: bool = c.isalpha()
res4: bool = d.isalpha()
res5: bool = e.isalpha()
assert res == True
assert res2 == False
assert res3 == False
assert res4 == False
assert res5 == False


def test_str_title():
Expand Down
1 change: 1 addition & 0 deletions lpython
Submodule lpython added at 467081
1 change: 1 addition & 0 deletions src/runtime/lpython_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ def _lpython_str_join(s:str, lis:list[str]) -> str:

def _lpython_str_isalpha(s: str) -> bool:
ch: str
if len(s) == 0: return False
for ch in s:
ch_ord: i32 = ord(ch)
if 65 <= ch_ord and ch_ord <= 90:
Expand Down

0 comments on commit 20b93b4

Please sign in to comment.