Skip to content
Open
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
4 changes: 3 additions & 1 deletion lib/str_to_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def str_to_int(string, *, default=None):
"""Returns the integer value of the string if the string is numeric,
otherwise returns default"""
try:
# TypeError is raised when the string is None.
# ValueError is raised when the string is not numeric.
return int(string)
except TypeError:
except (ValueError, TypeError):
return default