gh-80731: Avoid executing code in except block in cmd (GH-111740)

This commit is contained in:
Tian Gao 2023-11-10 13:13:29 -08:00 committed by GitHub
parent afac3c9b7e
commit 148af38cd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 3 deletions

View file

@ -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)