aboutsummaryrefslogtreecommitdiff
path: root/bindings/python/clang/cindex.py
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2013-03-19 15:30:48 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2013-03-19 15:30:48 +0000
commit11d6cd318df1459ed57b26912d5c7a5cf2c2f091 (patch)
tree2af499c6b4a01625cc8ccacead48c0173560c99f /bindings/python/clang/cindex.py
parent9a2f5d70dfb0eb739076d5bad1a779de9b201930 (diff)
cindex.py: Handle NULL pointers when parsing translation units
The code inside cindex.py was comparing NULL pointer returned by clang_parseTranslationUnit and clang_createTranslationUnit with None. However, as illustrated by the two tests I've added, those conditions were ineffective which resulted in assert triggering later on. Instead, a pointer is now treated as a boolean value, a NULL pointer being False. Contributed-by: Xavier Deguillard <deguilx@gmail.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177408 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/clang/cindex.py')
-rw-r--r--bindings/python/clang/cindex.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index e683f5ba72..70f4f36a2c 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -2015,7 +2015,7 @@ class TranslationUnit(ClangObject):
len(args), unsaved_array,
len(unsaved_files), options)
- if ptr is None:
+ if not ptr:
raise TranslationUnitLoadError("Error parsing translation unit.")
return cls(ptr, index=index)
@@ -2037,7 +2037,7 @@ class TranslationUnit(ClangObject):
index = Index.create()
ptr = conf.lib.clang_createTranslationUnit(index, filename)
- if ptr is None:
+ if not ptr:
raise TranslationUnitLoadError(filename)
return cls(ptr=ptr, index=index)