Off by one in generic_selection out of bounds check

Out of bounds check in generic_selection is using >= on list. Lists are zero based. If you put in a value that equals the number of items in the list you get an out of bounds error. 

Removed the equals part of the test as last item in list/dictionary items is len(list)-1 not len(list)
This commit is contained in:
Insanemal 2021-04-09 13:44:51 +10:00 committed by GitHub
parent 303dbd567a
commit acc2dac652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -184,7 +184,7 @@ def generic_select(options, input_text="Select one of the above by index or abso
return None
elif selected_option.isdigit():
selected_option = int(selected_option)
if selected_option >= len(options):
if selected_option > len(options):
raise RequirementError(f'Selected option "{selected_option}" is out of range')
selected_option = options[selected_option]
elif selected_option in options: