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

Optionally run patterns unrestricted #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nils
Copy link

@nils nils commented Mar 24, 2021

Hi @jackw01,

I'd like to write complex patterns with classes and everything Python provides, so this PR proposes a new command line flag --run-unsafe which does run the pattern code in an unrestricted way.

However, I have to admit that I'm not very experienced with Python, so I'd welcome every feedback you have concerning the code quality.

Best Regards,
Nils

@nils nils force-pushed the optionally-unrestricted branch from 8039b96 to bb4acd0 Compare October 13, 2021 11:03
@nils
Copy link
Author

nils commented Oct 13, 2021

Hi @jackw01, could you provide some feedback on this?

Any chances to get it merged? If not, I'd be happy to learn why :-)

  • because you don't see it in scope of this project
  • because the code quality needs to be improved
  • ... or let me know any other reason

@jackw01
Copy link
Owner

jackw01 commented Oct 15, 2021

I understand the motivation for having this feature to be able to use classes, helper functions, and global variables in patterns, but I would rather it be implemented using RestrictedPython instead of using the unsafe compile and executing the pattern with access to all existing global variables. If I were to implement this, I would allow each pattern to have a separate setup function that gets called once after the code is compiled to set up any classes or global variables that can then be used by the pattern function. I am not sure about the exact implementation details for this, but I will look into it when I have some free time.

The one use case I can see that this approach wouldn't cover is being able to read data from a file from within animation code, which could be solved by adding a command line flag like you have that would (unsafely) add open and other file-related functionality to the list of allowed globals.

@nils nils force-pushed the optionally-unrestricted branch from bb4acd0 to f7bf3f1 Compare July 31, 2022 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants