[gobject-introspection] giscanner: Don't fail on empty GTK-Doc comment blocks
- From: Dieter Verfaillie <dieterv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] giscanner: Don't fail on empty GTK-Doc comment blocks
- Date: Wed, 9 Jan 2013 21:53:30 +0000 (UTC)
commit 6b36bb4f78b7005aae8173c9c2712d7ef5d2c442
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date: Thu Jan 3 08:01:10 2013 +0100
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
giscanner/annotationparser.py | 25 ++++++++++++++-----------
tests/scanner/annotationparser/gi/syntax.xml | 8 ++++++++
2 files changed, 22 insertions(+), 11 deletions(-)
---
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 */</commentblock>
<test>
<!--
+ Not GTK-Doc
+ -->
+ <commentblock>/**
+*/</commentblock>
+</test>
+
+<test>
+ <!--
Technically not GTK-Doc, but we need to support this for backwards compatibility
-->
<commentblock>/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]