Index: clang/bindings/python/clang/cindex.py =================================================================== --- clang/bindings/python/clang/cindex.py +++ clang/bindings/python/clang/cindex.py @@ -207,7 +207,7 @@ conf.lib.clang_disposeString(self) @staticmethod - def from_result(res, fn, args): + def from_result(res, fn=None, args=None): assert isinstance(res, _CXString) return conf.lib.clang_getCString(res) @@ -459,8 +459,7 @@ """The command-line option that disables this diagnostic.""" disable = _CXString() conf.lib.clang_getDiagnosticOption(self, byref(disable)) - - return conf.lib.clang_getCString(disable) + return _CXString.from_result(disable) def format(self, options=None): """ @@ -473,8 +472,7 @@ options = conf.lib.clang_defaultDiagnosticDisplayOptions() if options & ~Diagnostic._FormatOptionsMask: raise ValueError('Invalid format options') - formatted = conf.lib.clang_formatDiagnostic(self, options) - return conf.lib.clang_getCString(formatted) + return conf.lib.clang_formatDiagnostic(self, options) def __repr__(self): return "" % ( Index: clang/bindings/python/tests/cindex/test_diagnostics.py =================================================================== --- clang/bindings/python/tests/cindex/test_diagnostics.py +++ clang/bindings/python/tests/cindex/test_diagnostics.py @@ -92,3 +92,11 @@ assert children[0].spelling.endswith('declared here') assert children[0].location.line == 1 assert children[0].location.column == 1 + +def test_diagnostic_string_repr(): + tu = get_tu('struct MissingSemicolon{}') + assert len(tu.diagnostics) == 1 + d = tu.diagnostics[0] + + assert repr(d) == ', spelling "expected \';\' after struct">' +