Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes empty string bug in str isalpha method #2484

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading