diff options
author | 2019-06-15 19:20:43 -0700 | |
---|---|---|
committer | 2019-06-15 22:45:43 -0700 | |
commit | ae959848e1332266464e824aa58a7c41fdce8312 (patch) | |
tree | 1a61db8bfc6b1b407268f74b7300db7d1acacd64 | |
parent | Snekbox: adjust for API change that merged stderr into stdout (diff) |
Snekbox: remove code template
Removing the template allows for line numbers in tracebacks to
correspond to the input code.
Since stderr has been merged into stdout, exceptions will already be
captured. Thus, it is redundant to wrap the code in a try-except.
Importing of the site module has been re-enabled on Snekbox which
automatically adds site-packages to sys.path. Thus, the virtual
environment does not need to be activated anymore in a template.
-rw-r--r-- | bot/cogs/snekbox.py | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index fd30aebcb..e10c6c2aa 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -18,16 +18,6 @@ from bot.utils.messages import wait_for_deletion log = logging.getLogger(__name__) -CODE_TEMPLATE = """ -venv_file = "/snekbox/.venv/bin/activate_this.py" -exec(open(venv_file).read(), dict(__file__=venv_file)) - -try: -{CODE} -except Exception as e: - print(e) -""" - ESCAPE_REGEX = re.compile("[`\u202E\u200B]{3,}") FORMATTED_CODE_REGEX = re.compile( r"^\s*" # any leading whitespace from the beginning of the string @@ -100,8 +90,7 @@ class Snekbox: f"stripping whitespace only:\n{code}" ) - code = textwrap.indent(code, " ") - return CODE_TEMPLATE.replace("{CODE}", code) + return code @staticmethod def get_results_message(results: dict) -> Tuple[str, str]: |