Skip to content

Commit 72e42f1

Browse files
committed
Avoid calling __getattr__ in get_object.
Also fix AttrCleaner's temporary __getattr__.
1 parent ba8b0e3 commit 72e42f1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

bpython/inspection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __enter__(self):
6464
__getattr__ = getattr(type_, '__getattr__', None)
6565
if __getattr__ is not None:
6666
try:
67-
setattr(type_, '__getattr__', (lambda _: None))
67+
setattr(type_, '__getattr__', (lambda *_, **__: None))
6868
except TypeError:
6969
__getattr__ = None
7070
__getattribute__ = getattr(type_, '__getattribute__', None)

bpython/repl.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,12 @@ def current_string(self, concatenate=False):
376376
return ''.join(string)
377377

378378
def get_object(self, name):
379-
if name in self.interp.locals:
380-
return self.interp.locals[name]
381-
else:
382-
return eval(name, self.interp.locals)
379+
attributes = name.split('.')
380+
obj = eval(attributes.pop(0), self.interp.locals)
381+
while attributes:
382+
with inspection.AttrCleaner(obj):
383+
obj = getattr(obj, attributes.pop(0))
384+
return obj
383385

384386
def get_args(self):
385387
"""Check if an unclosed parenthesis exists, then attempt to get the

0 commit comments

Comments
 (0)