summaryrefslogtreecommitdiff
path: root/giscanner/annotationparser.py
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2013-01-03 08:01:10 +0100
committerDieter Verfaillie <dieterv@optionexplicit.be>2013-01-09 20:29:55 +0100
commit6b36bb4f78b7005aae8173c9c2712d7ef5d2c442 (patch)
tree59d37cd3f8fe9c150017115311cfea504dc92ecd /giscanner/annotationparser.py
parentd20a932d36107eed33bd57b4ce27868b8e52802e (diff)
downloadgobject-introspection-6b36bb4f78b7005aae8173c9c2712d7ef5d2c442.tar.gz
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
Diffstat (limited to 'giscanner/annotationparser.py')
-rw-r--r--giscanner/annotationparser.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index f5455903..d4b24992 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: