提交 80559e48 编写于 作者: R Radostin Stoyanov 提交者: Daniel P. Berrangé

apibuild: Use isinstance for type checking

The isinstance() function [1] returns true if an object argument is an
instance of a classinfo argument or of a direct, indirect subclass
thereof.

1: https://docs.python.org/3/library/functions.html#isinstanceReviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Signed-off-by: NRadostin Stoyanov <rstoyanov1@gmail.com>
上级 1554eafb
......@@ -742,7 +742,7 @@ class CParser:
return line
def cleanupComment(self):
if type(self.comment) != type(""):
if not isinstance(self.comment, str):
return
# remove the leading * on multi-line comments
lines = self.comment.splitlines(True)
......@@ -2223,9 +2223,8 @@ class docBuilder:
output.write(" <struct name='%s' file='%s' type='%s'" % (
name, self.modulename_file(id.header), id.info))
name = id.info[7:]
if name in self.idx.structs and ( \
type(self.idx.structs[name].info) == type(()) or
type(self.idx.structs[name].info) == type([])):
if (name in self.idx.structs and
isinstance(self.idx.structs[name].info, (list, tuple))):
output.write(">\n")
try:
for field in self.idx.structs[name].info:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册