From: Philip Jenvey Date: Wed, 18 Jul 2007 20:49:12 +0000 (+0000) Subject: fix skipping of class definitions without parens X-Git-Tag: 1.0~426 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=732758b4819effdac88ed182ee0788d4cf89a7c6;p=thirdparty%2Fbabel.git fix skipping of class definitions without parens fixes #55 --- diff --git a/babel/messages/extract.py b/babel/messages/extract.py index d7d54e74..fd4a7e89 100644 --- a/babel/messages/extract.py +++ b/babel/messages/extract.py @@ -295,6 +295,10 @@ def extract_python(fileobj, keywords, comment_tags, options): if funcname: message_lineno = lineno call_stack += 1 + elif in_def and tok == OP and value == ':': + # End of a class definition without parens + in_def = False + continue elif call_stack == -1 and tok == COMMENT: # Strip the comment token from the line value = value.decode(encoding)[1:].strip() diff --git a/babel/messages/tests/extract.py b/babel/messages/tests/extract.py index bfcc4fdf..5ee64b44 100644 --- a/babel/messages/tests/extract.py +++ b/babel/messages/tests/extract.py @@ -70,12 +70,15 @@ def render_body(context,x,y=_('Page arg 1'),z=_('Page arg 2'),**pageargs): pass def ngettext(y='arg 1',z='arg 2',**pageargs): pass +class Meta: + verbose_name = _('log entry') """) messages = list(extract.extract_python(buf, extract.DEFAULT_KEYWORDS.keys(), [], {})) self.assertEqual([(3, '_', u'Page arg 1', []), - (3, '_', u'Page arg 2', [])], + (3, '_', u'Page arg 2', []), + (8, '_', u'log entry', [])], messages) def test_multiline(self):