From: Mark Dickinson Date: Tue, 4 Aug 2009 21:56:04 +0000 (+0000) Subject: Issue #6620: Slightly safer code for _grouping_intervals in the locale X-Git-Tag: v2.7a1~680 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b4567347310031b2e28f26e7d8b4430722de2f9;p=thirdparty%2FPython%2Fcpython.git Issue #6620: Slightly safer code for _grouping_intervals in the locale module. Fixes a 'possible use before assignment' warning from pylint. Thanks Vincent Legoll. --- diff --git a/Lib/locale.py b/Lib/locale.py index 879725feb94a..f0733999d2c3 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