Skip to content

Commit c12c68e

Browse files
committed
Ensure default value of "comment" is comment_t class
Enforce that the resultant object found in the comment property is a comment_t object.
1 parent 610a273 commit c12c68e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pygccxml/parser/scanner.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ def _handle_comment(self, declaration):
224224
comm_line = comm_line.rstrip("\n")
225225
comment_text.append(comm_line)
226226
comm_decl.text = comment_text
227-
return comm_decl
227+
return comm_decl
228+
else:
229+
return declarations.comment.comment_t()
228230

229231
def endDocument(self):
230232
# updating membership
@@ -236,7 +238,8 @@ def endDocument(self):
236238
members_mapping[id(decl)] = members
237239
self.__members = members_mapping
238240
for gccxml_id, decl in self.__declarations.items():
239-
decl.comment = self._handle_comment(decl)
241+
if not isinstance(decl.comment, declarations.comment.comment_t):
242+
decl.comment = self._handle_comment(decl)
240243

241244
def declarations(self):
242245
return self.__declarations

0 commit comments

Comments
 (0)