Open nimamg opened 1 year ago
We have not tried yet, mostly because of priority for other features. However, if you have a concrete analysis that needs them, let us know and we can try. For keeping a note, here are my ideas for how they might work:
with
: we can have two hooks, one for entering the context and one for exiting. This should be fairly easy to implement.function_enter
and function_exit
are instrumented. The only thing lacking is to know if a function is a decorator or not.
- decorators: they should work with the current version as the
function_enter
andfunction_exit
are instrumented. The only thing lacking is to know if a function is a decorator or not.
Couldn't you get that from the AST?
Couldn't you get that from the AST?
Yes, we can. Now the question is should we have a separate hook for decorators, or have parameter in the hook that specifies if the function is a decorator?
We now (e9c831a) can support with
statements (context managers). It currently only supports one context manager in the statement (e.g. with open("foo.txt") as f:
and not with open("foo.txt") as f, open("bar.txt") as b:
), but we are working on extending it to multiple ones.
Please let us know if this serves your purposes, and if there are any issues.
DynaPyt does not attempt to instrument decorators and context manager usage (the "with" keyword). Is there a specific reason for that? Have you attempted to add them and faced any problems or challenges preventing it, or can they be added to the project? Thanks!