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

fix custom codefile execution syntax error #61

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

Conversation

odeliap
Copy link

@odeliap odeliap commented Dec 11, 2023

I've seen this issue around, where when specifying a custom file the user gets back a syntax error. Tested and verified that the problem is that exec is being called on the filename instead of the file contents. The exec function is meant to execute a string of Python code, not to execute the file by its path. The exec command typically works like:

# Define the path to the file
file_path = 'YOURPATH'

# Read the content of the file
with open(file_path, 'r') as file:
    file_content = file.read()

# Execute the content of the file
exec(file_content)

but it's being called on self.codefile where self.codefile is the file path (and not the actual python code). This would cause a syntax error since exec expects python code and not the file path -- which is exactly what we're seeing.

This fix should resolve this. Thanks!

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.

1 participant