I am using the pysandbox to run the Python code in sandbox environment. I got it up and running, but I want it to support python datetime module. As per the documentation, I added 'datetime' in the config as follows,
sandbox = SandboxConfig('datetime', cpython_restricted=False)
but if I run the code I still get the error,
'global name datetime is not defined'
There is some issue with the pysandbox. Looks like you are passing some parameter to the sandboxed function through the
localsvariable. In this case, the import is not added to the global namespace.Simply write
global datetimeright after you import it and it will work. Otherwise, you may also pass it as a function parameter.