diff --git a/chirp/settings.py b/chirp/settings.py index 4fa49b89..1e3b1029 100644 --- a/chirp/settings.py +++ b/chirp/settings.py @@ -14,6 +14,7 @@ # along with this program. If not, see . import logging +import warnings from chirp import chirp_common @@ -226,6 +227,14 @@ class RadioSettingValueList(RadioSettingValue): def __init__(self, options, current=None, current_index=0): RadioSettingValue.__init__(self) self._options = list(options) + if current is not None: + # Using current_index is safer than using current because we can + # gracefully handle out-of-range values without crashing. All new + # code should use current_index and old code should be fixed. + warnings.warn( + 'RadioSettingValueList should be provided with ' + 'current_index instead of current (value) for ' + 'safety', FutureWarning, stacklevel=2) self.queue_current(current if current is not None else int(current_index))