-
Notifications
You must be signed in to change notification settings - Fork 41
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
Related library: pure_eval #83
Comments
@alexmojaki The initial commit to a git repository for asteval was in 2012: (see newville@67fb537). At that point, the code had existed for about a year or more, but was not yet using git - and I did not bother with svn-to-git for this code at that time. The library was already working pretty well and had some unit tests. Basically, the code was pulled out of a larger effort that eventually broke itself into separate libraries for Perhaps it would have been helpful if you and the other authors of |
The primary use case is to extract information from stack frames to be displayed in tracebacks or for other debugging or magic. For example it's used by stack_data in IPython and in sentry to show the values of some expressions alongside the variables in a frame. In these cases the code is trusted, it's written by the user of pure_eval rather than external untrusted users. But the namespace can contain arbitrary objects meaning innocent-looking operations like attribute access could cause arbitrary side effects which are probably not malicious but still unwanted. Hence pure_eval will not evaluate By contrast, asteval is worried about problematic code, but it expects that the namespace is safe and under control, so it will happily call any function it can find. It's a subtle enough difference that it took me a while to confirm that asteval doesn't actually fulfill pure_eval's use case, and someone coming across one of the two libraries might similarly take a while to realise that their use case actually requires the other (which they might not know exists yet).
|
@alexmojaki Yeah, I'm still sort of baffled by what you're doing (or trying to do), both with your code and in this Issue. For sure, if your "Rectangle" was remotely more complicated, accessing instance attributes could have side effects. Python is a dynamic language and neither the complexity nor the resources needed to access an object can be predicted easily from its name, or even really from its datatype. I'm sort of not getting the "here's what this code does" part. It might be that I can't really follow the code in your Readme -- the code snippets are incomplete. Is this something that you think would be useful for asteval? |
I don't have a real goal with this issue, nor do I suggest using pure_eval in asteval. I just thought you'd be interested in the library. The two libraries are similar enough that one might think they have the same goal. One day you might have someone asking you how to accomplish something with asteval and it'll turn out that asteval is wrong for them, what they need is pure_eval. I would like to know what it is that isn't clear about the README. You give the library an AST node, it evaluates it if it knows it can do so without triggering side effects (i.e. calling user code) otherwise it raises an exception. |
Not actually an issue, just thought you might be interested to know about https://github.com/alexmojaki/pure_eval. Its actual goal is quite different, but it's still in a similar space.
The text was updated successfully, but these errors were encountered: