From 6741794dd420c6b9775a188690dbf265037cd69f Mon Sep 17 00:00:00 2001 From: Jack DeVries <58614260+jdevries3133@users.noreply.github.com> Date: Thu, 29 Jul 2021 10:01:21 -0400 Subject: [PATCH] bpo-44752: refactor part of rlcompleter.Completer.attr_matches (GH-27433) --- Lib/rlcompleter.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py index 34b259916e8..98b7930b32f 100644 --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -186,13 +186,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 == '_':