From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 29 Jul 2021 15:46:07 +0000 (-0700) Subject: bpo-44752: refactor part of rlcompleter.Completer.attr_matches (GH-27433) (GH-27446) X-Git-Tag: v3.9.7~109 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93d90871d216625b8d9db0fa59693953353d19ae;p=thirdparty%2FPython%2Fcpython.git bpo-44752: refactor part of rlcompleter.Completer.attr_matches (GH-27433) (GH-27446) (cherry picked from commit 6741794dd420c6b9775a188690dbf265037cd69f) Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com> --- diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py index f620dcf7bf26..923f5c054115 100644 --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -179,13 +179,10 @@ class Completer: # property method, which is not desirable. matches.append(match) continue - try: - val = getattr(thisobject, word) - except Exception: - pass # Include even if attribute not set + if (value := getattr(thisobject, word, None)) is not None: + matches.append(self._callable_postfix(value, match)) else: - match = self._callable_postfix(val, match) - matches.append(match) + matches.append(match) if matches or not noprefix: break if noprefix == '_':