Kaydet (Commit) 4b456734 authored tarafından Mark Dickinson's avatar Mark Dickinson

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

module.  Fixes a 'possible use before assignment' warning from pylint.
Thanks Vincent Legoll.
üst 4809c737
...@@ -114,12 +114,15 @@ def localeconv(): ...@@ -114,12 +114,15 @@ def localeconv():
# Iterate over grouping intervals # Iterate over grouping intervals
def _grouping_intervals(grouping): def _grouping_intervals(grouping):
last_interval = None
for interval in grouping: for interval in grouping:
# if grouping is -1, we are done # if grouping is -1, we are done
if interval == CHAR_MAX: if interval == CHAR_MAX:
return return
# 0: re-use last group ad infinitum # 0: re-use last group ad infinitum
if interval == 0: if interval == 0:
if last_interval is None:
raise ValueError("invalid grouping")
while True: while True:
yield last_interval yield last_interval
yield interval yield interval
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment