diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-02 12:46:48 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-02 12:46:48 +0000 |
| commit | b5ea630dfd1a0d3e5c08d8959158608dd213d9aa (patch) | |
| tree | 414ded0ca2d2732345c4d423b8f3cd326d9097e8 /bindings/python | |
| parent | 4bc3002fe03f32a9d85720bece65eeda40c75742 (diff) | |
Notes
Diffstat (limited to 'bindings/python')
| -rw-r--r-- | bindings/python/clang/cindex.py | 8 | ||||
| -rw-r--r-- | bindings/python/tests/cindex/test_diagnostics.py | 8 | ||||
| -rw-r--r-- | bindings/python/tests/cindex/test_exception_specification_kind.py (renamed from bindings/python/tests/test_exception_specification_kind.py) | 0 |
3 files changed, 11 insertions, 5 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 236803a9ab9b..4069ab8650d6 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -207,7 +207,7 @@ class _CXString(Structure): 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 @@ class Diagnostic(object): """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 @@ class Diagnostic(object): 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 "<Diagnostic severity %r, location %r, spelling %r>" % ( diff --git a/bindings/python/tests/cindex/test_diagnostics.py b/bindings/python/tests/cindex/test_diagnostics.py index ba6e545e8b1a..23cbe89f6581 100644 --- a/bindings/python/tests/cindex/test_diagnostics.py +++ b/bindings/python/tests/cindex/test_diagnostics.py @@ -92,3 +92,11 @@ def test_diagnostic_children(): 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) == '<Diagnostic severity 3, location <SourceLocation file \'t.c\', line 1, column 26>, spelling "expected \';\' after struct">' + diff --git a/bindings/python/tests/test_exception_specification_kind.py b/bindings/python/tests/cindex/test_exception_specification_kind.py index 543d47f7db97..543d47f7db97 100644 --- a/bindings/python/tests/test_exception_specification_kind.py +++ b/bindings/python/tests/cindex/test_exception_specification_kind.py |
