aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Matteo Bertucci <[email protected]>2021-01-25 13:47:44 +0100
committerGravatar GitHub <[email protected]>2021-01-25 13:47:44 +0100
commit134a2c61a51c50d2a8c6e9c19e9ffeca4152cc4d (patch)
tree58567943b28ecb079a3ea8c233bda2230a1c5dab
parentFixed python_general const in server command (diff)
parentRemoved the blank lines from __init__ function (diff)
Merge pull request #1383 from Inheritanc-e/remove_interpreter
Removed helper interpreter.
-rw-r--r--bot/exts/utils/internal.py3
-rw-r--r--bot/interpreter.py51
2 files changed, 0 insertions, 54 deletions
diff --git a/bot/exts/utils/internal.py b/bot/exts/utils/internal.py
index 3521c8fd4..a7ab43f37 100644
--- a/bot/exts/utils/internal.py
+++ b/bot/exts/utils/internal.py
@@ -15,7 +15,6 @@ from discord.ext.commands import Cog, Context, group, has_any_role
from bot.bot import Bot
from bot.constants import Roles
-from bot.interpreter import Interpreter
from bot.utils import find_nth_occurrence, send_to_paste_service
log = logging.getLogger(__name__)
@@ -30,8 +29,6 @@ class Internal(Cog):
self.ln = 0
self.stdout = StringIO()
- self.interpreter = Interpreter()
-
self.socket_since = datetime.utcnow()
self.socket_event_total = 0
self.socket_events = Counter()
diff --git a/bot/interpreter.py b/bot/interpreter.py
deleted file mode 100644
index b58f7a6b0..000000000
--- a/bot/interpreter.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from code import InteractiveInterpreter
-from io import StringIO
-from typing import Any
-
-from discord.ext.commands import Context
-
-import bot
-
-CODE_TEMPLATE = """
-async def _func():
-{0}
-"""
-
-
-class Interpreter(InteractiveInterpreter):
- """
- Subclass InteractiveInterpreter to specify custom run functionality.
-
- Helper class for internal eval.
- """
-
- write_callable = None
-
- def __init__(self):
- locals_ = {"bot": bot.instance}
- super().__init__(locals_)
-
- async def run(self, code: str, ctx: Context, io: StringIO, *args, **kwargs) -> Any:
- """Execute the provided source code as the bot & return the output."""
- self.locals["_rvalue"] = []
- self.locals["ctx"] = ctx
- self.locals["print"] = lambda x: io.write(f"{x}\n")
-
- code_io = StringIO()
-
- for line in code.split("\n"):
- code_io.write(f" {line}\n")
-
- code = CODE_TEMPLATE.format(code_io.getvalue())
- del code_io
-
- self.runsource(code, *args, **kwargs)
- self.runsource("_rvalue = _func()", *args, **kwargs)
-
- rvalue = await self.locals["_rvalue"]
-
- del self.locals["_rvalue"]
- del self.locals["ctx"]
- del self.locals["print"]
-
- return rvalue