summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl/reader.py
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2024-05-07 14:31:56 (GMT)
committerGitHub <noreply@github.com>2024-05-07 14:31:56 (GMT)
commite5413ec7831608f6cb4f39d805785cb1d7b67702 (patch)
tree2682de33e27eb0cf3161bfacd5f606db9319b105 /Lib/_pyrepl/reader.py
parent71080b8a0fe5da46fb97659060db76fd95a3fb61 (diff)
downloadcpython-e5413ec7831608f6cb4f39d805785cb1d7b67702.zip
cpython-e5413ec7831608f6cb4f39d805785cb1d7b67702.tar.gz
cpython-e5413ec7831608f6cb4f39d805785cb1d7b67702.tar.bz2
gh-118682: Revert forcing str commands, allow class commands in pyrepl (#118709)
Diffstat (limited to 'Lib/_pyrepl/reader.py')
-rw-r--r--Lib/_pyrepl/reader.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/_pyrepl/reader.py b/Lib/_pyrepl/reader.py
index e36f65c..d84c164 100644
--- a/Lib/_pyrepl/reader.py
+++ b/Lib/_pyrepl/reader.py
@@ -568,12 +568,16 @@ class Reader:
"""`cmd` is a tuple of "event_name" and "event", which in the current
implementation is always just the "buffer" which happens to be a list
of single-character strings."""
- assert isinstance(cmd[0], str)
trace("received command {cmd}", cmd=cmd)
- command_type = self.commands.get(cmd[0], commands.invalid_command)
- command = command_type(self, *cmd) # type: ignore[arg-type]
+ if isinstance(cmd[0], str):
+ command_type = self.commands.get(cmd[0], commands.invalid_command)
+ elif isinstance(cmd[0], type):
+ command_type = cmd[0]
+ else:
+ return # nothing to do
+ command = command_type(self, *cmd) # type: ignore[arg-type]
command.do()
self.after_command(command)