]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44752: refactor part of rlcompleter.Completer.attr_matches (GH-27433)
authorJack DeVries <58614260+jdevries3133@users.noreply.github.com>
Thu, 29 Jul 2021 14:01:21 +0000 (10:01 -0400)
committerGitHub <noreply@github.com>
Thu, 29 Jul 2021 14:01:21 +0000 (16:01 +0200)
Lib/rlcompleter.py

index 34b259916e8e7286efd02f14bac19720aaa343c0..98b7930b32fab32e387500dee01c7a2a68eb2e3a 100644 (file)
@@ -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 == '_':