[Python-checkins] bpo-44752: refactor part of rlcompleter.Completer.attr_matches (GH-27433) (GH-27447)

ambv webhook-mailer at python.org
Thu Jul 29 11:44:55 EDT 2021


https://github.com/python/cpython/commit/f8e13e35d12bee6e3447c791199522249ba7f05a
commit: f8e13e35d12bee6e3447c791199522249ba7f05a
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ambv <lukasz at langa.pl>
date: 2021-07-29T17:44:42+02:00
summary:

bpo-44752: refactor part of rlcompleter.Completer.attr_matches (GH-27433) (GH-27447)

(cherry picked from commit 6741794dd420c6b9775a188690dbf265037cd69f)

Co-authored-by: Jack DeVries <58614260+jdevries3133 at users.noreply.github.com>

files:
M Lib/rlcompleter.py

diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index 34b259916e8e7..98b7930b32fab 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -186,13 +186,10 @@ def attr_matches(self, text):
                         # 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 == '_':



More information about the Python-checkins mailing list