mirror of
https://github.com/python/cpython.git
synced 2025-09-09 18:32:22 +00:00
bpo-44752: Make rlcompleter not call @property
methods (GH-27401) (#27445)
* rlcompleter was calling these methods to identify whether to add
parenthesis to the completion, based on if the attribute is callable.
* for property objects, completion with parenthesis are never desirable.
* property methods with print statements behaved very strangely, which
was especially unfriendly to language newcomers. <tab> could suddenly
produce output unexpectedly.
(cherry picked from commit 50de8f74f8
)
Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com>
This commit is contained in:
parent
12fc0d28fc
commit
acaf3b9594
3 changed files with 41 additions and 5 deletions
|
@ -169,6 +169,16 @@ class Completer:
|
|||
if (word[:n] == attr and
|
||||
not (noprefix and word[:n+1] == noprefix)):
|
||||
match = "%s.%s" % (expr, word)
|
||||
if isinstance(getattr(type(thisobject), word, None),
|
||||
property):
|
||||
# bpo-44752: thisobject.word is a method decorated by
|
||||
# `@property`. What follows applies a postfix if
|
||||
# thisobject.word is callable, but know we know that
|
||||
# this is not callable (because it is a property).
|
||||
# Also, getattr(thisobject, word) will evaluate the
|
||||
# property method, which is not desirable.
|
||||
matches.append(match)
|
||||
continue
|
||||
try:
|
||||
val = getattr(thisobject, word)
|
||||
except Exception:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue