From 14f456b0c3b70021fa650a596f81e0cfa7bd8949 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Tue, 4 Feb 2020 22:18:56 -0500 Subject: Fixed a bug in a very unusual case and added some unit tests --- cmd2/utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'cmd2/utils.py') diff --git a/cmd2/utils.py b/cmd2/utils.py index 2f2efefa..c200085a 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -64,10 +64,11 @@ def str_to_bool(val: str) -> bool: :return: boolean value expressed in the string :raises: ValueError if the string does not contain a value corresponding to a boolean value """ - if val.capitalize() == str(True): - return True - elif val.capitalize() == str(False): - return False + if isinstance(val, str): + if val.capitalize() == str(True): + return True + elif val.capitalize() == str(False): + return False raise ValueError("must be True or False") -- cgit v1.2.1