diff --git a/Lib/locale.py b/Lib/locale.py index f6d174c8599..4ab3c6a48c3 100644 --- a/Lib/locale.py +++ b/Lib/locale.py @@ -121,12 +121,15 @@ def localeconv(): # Iterate over grouping intervals def _grouping_intervals(grouping): + last_interval = None for interval in grouping: # if grouping is -1, we are done if interval == CHAR_MAX: return # 0: re-use last group ad infinitum if interval == 0: + if last_interval is None: + raise ValueError("invalid grouping") while True: yield last_interval yield interval