Skip to content

Commit 93d9087

Browse files
bpo-44752: refactor part of rlcompleter.Completer.attr_matches (GH-27433) (GH-27446)
(cherry picked from commit 6741794) Co-authored-by: Jack DeVries <[email protected]>
1 parent acaf3b9 commit 93d9087

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Lib/rlcompleter.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,10 @@ def attr_matches(self, text):
179179
# property method, which is not desirable.
180180
matches.append(match)
181181
continue
182-
try:
183-
val = getattr(thisobject, word)
184-
except Exception:
185-
pass # Include even if attribute not set
182+
if (value := getattr(thisobject, word, None)) is not None:
183+
matches.append(self._callable_postfix(value, match))
186184
else:
187-
match = self._callable_postfix(val, match)
188-
matches.append(match)
185+
matches.append(match)
189186
if matches or not noprefix:
190187
break
191188
if noprefix == '_':

0 commit comments

Comments
 (0)