TheTechRobo/python-text-calculator

[REWRITE] BUG: TypeError: can only concatenate str (not "bool") to str

TheTechRobo opened this issue · 0 comments

Describe the bug
Makefile::test: TypeError: can only concatenate str (not "bool") to str.
To Reproduce
Steps to reproduce the behavior:

  1. make test

Logs

Welcome to Palc!                                 
Please enter a command...  Press any key failed.
False--------------------------------------------------------------------------------------------------------------------------------------------                      
                                                                   Oops!                                                                    
--------------------------------------------------------------------------------------------------------------------------------------------
You raised a TypeError! This is odd. If you are sure that your inputs were correct, please file a bug report at github.com/thetechrobo/python-text-calculator/issues.
For further information, get a backtrace.
Get a backtrace? Traceback (most recent call last):
  File "/home/thetechrobo/python-text-calculator/palc.py", line 128, in <module>
    mainloop()
  File "/home/thetechrobo/python-text-calculator/palc.py", line 117, in mainloop
    calc += keypress
TypeError: can only concatenate str (not "bool") to str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/thetechrobo/python-text-calculator/palc.py", line 140, in <module>
    if input(_("Get a backtrace? ")).lower().strip()[0] == "y":
IndexError: string index out of range
make: *** [Makefile:9: test] Error 1

Desktop (please complete the following information):

  • Debian Bullseye crouton chroot
  • Python 3.9.2
  • massive-huge-rewrite@7b7e0c486eb11be1f7da696e18f86db573fb7328

Culprit
The check for whether stdin is a terminal is failing; when the pressanykey() fails it returns False, and False cannot be added to a string.

We need to fix the isatty check AND add error handling for when pressanykey() does return false.