[utils] Fix get_integer_choice behaviour

In my defense, the original function was 100% generated by
GitHub Copilot.
This commit is contained in:
derrod 2021-12-30 19:05:23 +01:00
parent cd74af8832
commit d70f0daa22

View file

@ -21,11 +21,11 @@ def get_int_choice(prompt, default=None, min_choice=None, max_choice=None, retur
while True: while True:
try: try:
choice = int(input(prompt)) inp = input(prompt)
except ValueError: if not inp:
if default is not None:
return default return default
else: choice = int(inp)
except ValueError:
if return_on_invalid: if return_on_invalid:
return None return None
return_on_invalid = True return_on_invalid = True