From: Dieter Verfaillie Date: Thu, 3 Jan 2013 07:01:10 +0000 (+0100) Subject: giscanner: Don't fail on empty GTK-Doc comment blocks X-Git-Tag: GOBJECT_INTROSPECTION_1_35_4~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b36bb4f78b7005aae8173c9c2712d7ef5d2c442;p=platform%2Fupstream%2Fgobject-introspection.git giscanner: Don't fail on empty GTK-Doc comment blocks A completely empty GTK-Doc comment block (/**\n*/) resulted in an unfriendly backtrace, complaining about an "AttributeError: 'NoneType' object has no attribute 'comment'" This fixes the issue and adds a test case. https://bugzilla.gnome.org/show_bug.cgi?id=690850 --- diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index f545590..d4b2499 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -1119,20 +1119,23 @@ class AnnotationParser(object): ######################################################################## # Finished parsing this comment block. ######################################################################## - # We have picked up a couple of \n characters that where not - # intended. Strip those. - if comment_block.comment: - comment_block.comment = comment_block.comment.strip() + if comment_block: + # We have picked up a couple of \n characters that where not + # intended. Strip those. + if comment_block.comment: + comment_block.comment = comment_block.comment.strip() - for tag in comment_block.tags.values(): - self._clean_comment_block_part(tag) + for tag in comment_block.tags.values(): + self._clean_comment_block_part(tag) - for param in comment_block.params.values(): - self._clean_comment_block_part(param) + for param in comment_block.params.values(): + self._clean_comment_block_part(param) - # Validate and store block. - comment_block.validate() - return comment_block + # Validate and store block. + comment_block.validate() + return comment_block + else: + return None def _clean_comment_block_part(self, part): if part.comment: diff --git a/tests/scanner/annotationparser/gi/syntax.xml b/tests/scanner/annotationparser/gi/syntax.xml index 83c56b9..f07e4fb 100644 --- a/tests/scanner/annotationparser/gi/syntax.xml +++ b/tests/scanner/annotationparser/gi/syntax.xml @@ -71,6 +71,14 @@ something */ + /** +*/ + + + + /**