summaryrefslogtreecommitdiffstats
path: root/Lib/cmd.py
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2023-11-10 21:13:29 (GMT)
committerGitHub <noreply@github.com>2023-11-10 21:13:29 (GMT)
commit148af38cd0adc1c2dde3c937ebbda4ee60b27b33 (patch)
tree83b6f242e0671d5fa7fcfc6ac970170a52128ad2 /Lib/cmd.py
parentafac3c9b7eace4a3e503e93bb76eda32d8217ad7 (diff)
downloadcpython-148af38cd0adc1c2dde3c937ebbda4ee60b27b33.zip
cpython-148af38cd0adc1c2dde3c937ebbda4ee60b27b33.tar.gz
cpython-148af38cd0adc1c2dde3c937ebbda4ee60b27b33.tar.bz2
gh-80731: Avoid executing code in except block in cmd (GH-111740)
Diffstat (limited to 'Lib/cmd.py')
-rw-r--r--Lib/cmd.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/cmd.py b/Lib/cmd.py
index 88ee7d3..e933b8d 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -210,9 +210,8 @@ class Cmd:
if cmd == '':
return self.default(line)
else:
- try:
- func = getattr(self, 'do_' + cmd)
- except AttributeError:
+ func = getattr(self, 'do_' + cmd, None)
+ if func is None:
return self.default(line)
return func(arg)