[clang] [libclang/python] Add some logical typing changes. (PR #138074)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 30 19:50:53 PDT 2025
================
@@ -3466,6 +3479,8 @@ def get_tokens(self, locations=None, extent=None):
"""
if locations is not None:
extent = SourceRange(start=locations[0], end=locations[1])
+ if extent is None:
+ raise TypeError("get_tokens() requires at least one argument")
----------------
DeinAlptraum wrote:
This previously returned the following error:
`ctypes.ArgumentError: argument 2: TypeError: expected SourceRange instance instead of NoneType`
from the library function since it gets passed `None`. This moves the error into `get_tokens` on Python side, gives a more explicit explanation and lets us guarantee that `TokenGroup.get_tokens()` is always passed a `SourceRange`
https://github.com/llvm/llvm-project/pull/138074
More information about the cfe-commits
mailing list