-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[libclang/python] Fix get_exception_specification_kind
#101548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Jannick Kremer (DeinAlptraum) ChangesThis fixes a bug with Full diff: https://github.com/llvm/llvm-project/pull/101548.diff 2 Files Affected:
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index 2038ef6045c7d..c251c46a04adf 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -2654,7 +2654,7 @@ def get_exception_specification_kind(self):
the ExceptionSpecificationKind enumeration.
"""
return ExceptionSpecificationKind.from_id(
- conf.lib.clang.getExceptionSpecificationType(self)
+ conf.lib.clang_getExceptionSpecificationType(self)
)
@property
diff --git a/clang/bindings/python/tests/cindex/test_exception_specification_kind.py b/clang/bindings/python/tests/cindex/test_exception_specification_kind.py
index 8e2a6b5c50223..6653c22eaf9cd 100644
--- a/clang/bindings/python/tests/cindex/test_exception_specification_kind.py
+++ b/clang/bindings/python/tests/cindex/test_exception_specification_kind.py
@@ -13,7 +13,7 @@
def find_function_declarations(node, declarations=[]):
if node.kind == clang.cindex.CursorKind.FUNCTION_DECL:
- declarations.append((node.spelling, node.exception_specification_kind))
+ declarations.append(node)
for child in node.get_children():
declarations = find_function_declarations(child, declarations)
return declarations
@@ -33,4 +33,7 @@ def test_exception_specification_kind(self):
("square2", ExceptionSpecificationKind.BASIC_NOEXCEPT),
("square3", ExceptionSpecificationKind.COMPUTED_NOEXCEPT),
]
- self.assertListEqual(declarations, expected)
+ from_cursor = [(node.spelling, node.exception_specification_kind) for node in declarations]
+ from_type = [(node.spelling, node.type.get_exception_specification_kind()) for node in declarations]
+ self.assertListEqual(from_cursor, expected)
+ self.assertListEqual(from_type, expected)
|
✅ With the latest revision this PR passed the Python code formatter. |
@Endilll I found another bug on the way, so here's a fix+test. Does this need a release note under |
Yes, the general approach is that every change should come with a test and a release note. On a different note, I wonder if there's a way to prevent this kind of bugs. Seems quite unfortunate that our python binding might not work because of something this silly. |
I can't think of any more genereal approach that prevents this sort of problem. Type checking would help with this (e.g. giving an error when an unknown attribute is called on an object) though it wouldn't have worked in this specific case... otherwise nothing to do but add more tests I guess. |
get_exception_specification_kind
Could you merge this for me? On related note, do you think my contributions would count for "a track record of submitting high quality patches", i.e. should I apply for commit access? |
Done.
You have unread messages in Discord :) |
To this end, I consider you eligible, as I mentioned offline yesterday. |
Fix a bug with
get_exception_specification_kind
. The function did not work before. Also add a test that confirms that it works now.