# HG changeset patch # User pjenvey # Date 1203358170 0 # Node ID 8c634fa877930e2431e55ffc6ba7470d4641bea6 # Parent 0f23b90ded7e50b5d8053ce8f5d02c98e31f0e59 fix invalid message extraction methods causing: UnboundLocalError: local variable 'func' referenced before assignment thanks cramm diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Version 0.9.3 +http://svn.edgewall.org/repos/babel/tags/0.9.3/ +(?, from branches/stable/0.9.x) + +* Fixed invalid message extraction methods causing an UnboundLocalError. + + Version 0.9.2 http://svn.edgewall.org/repos/babel/tags/0.9.2/ (Feb 4 2007, from branches/stable/0.9.x) diff --git a/babel/messages/extract.py b/babel/messages/extract.py --- a/babel/messages/extract.py +++ b/babel/messages/extract.py @@ -219,6 +219,7 @@ :rtype: `list` :raise ValueError: if the extraction method is not registered """ + func = None if ':' in method: module, clsname = method.split(':', 1) func = getattr(__import__(module, {}, {}, [clsname]), clsname) diff --git a/babel/messages/tests/extract.py b/babel/messages/tests/extract.py --- a/babel/messages/tests/extract.py +++ b/babel/messages/tests/extract.py @@ -325,6 +325,10 @@ (8, u'Rabbit', []), (10, (u'Page', u'Pages'), [])], messages) + def test_invalid_extract_method(self): + buf = StringIO('') + self.assertRaises(ValueError, list, extract.extract('spam', buf)) + def test_different_signatures(self): buf = StringIO(""" foo = _('foo', 'bar')