bchao1 / bullet

🚅 Interactive prompts made simple. Build a prompt like stacking blocks.
https://pypi.org/project/bullet/
MIT License
3.55k stars 113 forks source link

Fix YesNo Error #50

Closed stypr closed 4 years ago

stypr commented 5 years ago

Summary

When YesNo is launched for first time and arrow key (up) is pressed, the application crashes. catching AttributeError should help to fix the bug.

Crash Information

crash.py

from bullet import YesNo,colors

if __name__ == "__main__":
    cli = YesNo("Are you sure to continue? ",
        word_color = colors.foreground["yellow"])
    print(cli.launch())

command log

$ python3 crash.py
[y/n] Are you sure to continue? [y]Traceback (most recent call last):
  File "crash.py", line 6, in <module>
    print(cli.launch())
  File "/usr/local/lib/python3.7/site-packages/bullet/client.py", line 393, in launch
    if not self.valid(ans):
  File "/usr/local/lib/python3.7/site-packages/bullet/client.py", line 377, in valid
    ans = ans.lower()
AttributeError: 'NoneType' object has no attribute 'lower'

OS: OSX 10.14.3 Python version: 3.7.3

rcfox commented 5 years ago

It seems like the higher-level issue is that myInput.input() is returning None, when it should only ever return a string.

Your fix seems worthwhile, but the return statement at line 92 should also be a continue.

stypr commented 5 years ago

@rcfox seems like that one in line 92 is the root cause of this bug. I think the developer needs to fix it asap..

bchao1 commented 4 years ago

I've fixed this issue in another fashion. Will update the package soon.