diff options
author | Robin Jarry <robin.jarry@6wind.com> | 2020-03-31 15:00:14 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-04-03 14:34:42 +0200 |
commit | 2da60a08de6f146f5dff78db3d01bee10ed375dc (patch) | |
tree | 5c0ce24b9c9a3b96e5f1213eb8da55b97b00408e /astroid/nodes.py | |
parent | 2e1ba8eb47694439215b866564c4699039b86ec9 (diff) | |
download | astroid-git-2da60a08de6f146f5dff78db3d01bee10ed375dc.tar.gz |
Inspect compiled CFFI extension members
To use a CFFI extension, its "lib" symbol gives access to the exported
C symbols and its "ffi" symbol gives access to low-level utilities.
An import such as the following is required:
from _compiled_extension_module import ffi
from _compiled_extension_module import lib
Then in the code, these objects are used to access the C symbols:
pp = ffi.cast('struct mystruct *', p)
lib.exported_c_function(pp)
Even if "_compiled_extension_module" is added to
AstroidManager.extension_package_whitelist, the "ffi" and "lib" objects
are not analyzed properly since they do not fall into any of the
supported categories of objects. A dummy "builtin.module" node is
inserted in their place preventing tools like pylint to properly detect
object membership. Thus producing invalid errors:
Instance of 'module' has no 'cast' member [no-member]
Instance of 'module' has no 'exported_c_function' member [no-member]
Both these objects define __all__ attributes which lists their exported
symbols. The presence of __all__ means that dir(member) will work and
that object_build may be called recursively on that member.
Insert a Module node to represent these objects and add their members to
the built AST.
Link: https://cffi.readthedocs.io/en/latest/overview.html#main-mode-of-usage
Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
Diffstat (limited to 'astroid/nodes.py')
0 files changed, 0 insertions, 0 deletions