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

The default value of locals for exec should be None instead of {} #16

Open
welfare520 opened this issue Nov 6, 2024 · 0 comments
Open

Comments

@welfare520
Copy link

This code will fail, with an error: NameError("name 're' is not defined")
code = """
import re

def return_parts(value):
parts = re.split(r'[,.]', value)
return parts

print(return_parts("100,36"))
"""
python_repl = PythonREPL()
python_repl.run(code)

This is because the default value {} of locals overrides the imported packages. Therefore the default value of locals in the class PythonREPL should be None instead of {}

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

No branches or pull requests

1 participant