Issue #6620: Slightly safer code for _grouping_intervals in the locale

module.  Fixes a 'possible use before assignment' warning from pylint.
Thanks Vincent Legoll.
This commit is contained in:
Mark Dickinson 2009-08-04 21:56:04 +00:00
parent 4809c737d3
commit 4b45673473
1 changed files with 3 additions and 0 deletions

View File

@ -114,12 +114,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