From c12d6a027662c978fc418c6fb584222fb3638483 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Sat, 22 Sep 2012 17:52:29 +0000 Subject: Fix cindex.py compatibility with older libclang.so The issue is that we were calling clang_getCompletionBriefComment unconditionally. New we check if this function is available before calling it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164464 91177308-0d34-0410-b5e6-96231b3b80d8 --- bindings/python/clang/cindex.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'bindings') diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 770ff0e0fe..edd3e707f7 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1737,7 +1737,9 @@ class CompletionString(ClangObject): @property def briefComment(self): - return conf.lib.clang_getCompletionBriefComment(self.obj) + if conf.function_exists("clang_getCompletionBriefComment"): + return conf.lib.clang_getCompletionBriefComment(self.obj) + return _CXString() def __repr__(self): return " | ".join([str(a) for a in self]) \ @@ -3097,6 +3099,13 @@ class Config: return library + def function_exists(self, name): + try: + getattr(self.lib, name) + except AttributeError: + return False + + return True def register_enumerations(): for name, value in clang.enumerations.TokenKinds: -- cgit v1.2.1