summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-08-04 21:56:04 +0000
committerMark Dickinson <dickinsm@gmail.com>2009-08-04 21:56:04 +0000
commit0653e5c1e09c92b59115996776c1e4677ee383b7 (patch)
treeb75f85ace83c074c138ec21ac019784e0abd2ce8
parentf3f9ed0cedc62a5ebf0254d8fdeaa6cf46bbd522 (diff)
downloadcpython-0653e5c1e09c92b59115996776c1e4677ee383b7.tar.gz
Issue #6620: Slightly safer code for _grouping_intervals in the locale
module. Fixes a 'possible use before assignment' warning from pylint. Thanks Vincent Legoll.
-rw-r--r--Lib/locale.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/locale.py b/Lib/locale.py
index 879725feb9..f0733999d2 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -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