From b387b939e2b7a024f1cae8401b94887fc264475a Mon Sep 17 00:00:00 2001 From: Jack DeVries Date: Wed, 28 Jul 2021 18:54:19 -0400 Subject: [PATCH] bpo-44752: refactor part of rlcompleter.Completer.attr_matches --- Lib/rlcompleter.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py index c06388e8d9c2dd8..33a332dc63141d7 100644 --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -176,13 +176,10 @@ def attr_matches(self, text): if (word[:n] == attr and not (noprefix and word[:n+1] == noprefix)): match = "%s.%s" % (expr, word) - 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 == '_':