Skip to content
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

free variables in-line python #205

Closed
yaythomas opened this issue Dec 6, 2020 · 1 comment · Fixed by #210
Closed

free variables in-line python #205

yaythomas opened this issue Dec 6, 2020 · 1 comment · Fixed by #210
Assignees
Labels
enhancement new features type: core core functionality type: step steps up next features that are more or less on the TODO list

Comments

@yaythomas
Copy link
Member

For both !py -strings and pypyr.steps.py, add support for free variables.

This is less edge case than it might sound: it comes up with very unfriendly and not easily understood errors when you attempt to use nested comprehensions:

[(x, y) for x in list1 for y in list2]. In this case, list2 will not resolve even if it is in context, leading to much WTF-ing for something that looks like it should work and in fact does work when you run it against the normal python compiler.

These pypyr inline python functions rely on eval and exec under the hood. Both of these, although taking both a globals and locals argument, only resolve free variables against globals.

@yaythomas yaythomas added type: core core functionality type: step steps labels Dec 6, 2020
@yaythomas yaythomas self-assigned this Dec 6, 2020
@yaythomas yaythomas added this to To do in pypyr roadmap via automation Dec 6, 2020
@yaythomas yaythomas added the enhancement new features label Dec 6, 2020
@yaythomas yaythomas added the up next features that are more or less on the TODO list label Dec 7, 2020
yaythomas added a commit that referenced this issue Dec 25, 2020
…pace. See docs/adr/0001-namespace-on-eval-and-exec.md.closes #205.
yaythomas added a commit that referenced this issue Dec 25, 2020
…pace. See docs/adr/0001-namespace-on-eval-and-exec.md.closes #205.
pypyr roadmap automation moved this from To do to Done Dec 26, 2020
yaythomas added a commit that referenced this issue Dec 26, 2020
…pace. See docs/adr/0001-namespace-on-eval-and-exec.md.closes #205.
@yaythomas
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new features type: core core functionality type: step steps up next features that are more or less on the TODO list
Projects
pypyr roadmap
  
Done
Development

Successfully merging a pull request may close this issue.

1 participant