From d1150cfdae2fc7b5d302cad0fcc3738fe2df7c5d Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 17 Mar 2013 13:56:54 +0100 Subject: [PATCH] List allowed attributes in Generator.__getattr__ --- jedi/evaluate_representation.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jedi/evaluate_representation.py b/jedi/evaluate_representation.py index 019e038b..f9bbd2c9 100644 --- a/jedi/evaluate_representation.py +++ b/jedi/evaluate_representation.py @@ -769,11 +769,12 @@ class Generator(use_metaclass(cache.CachedMetaClass, pr.Base)): debug.warning('Tried to get array access on a generator', self) return [] - @property - def parent(self): - return self.func.parent - def __getattr__(self, name): + if name not in ['start_pos', 'end_pos', 'parent', 'get_imports', + 'asserts', 'doc', 'docstr', 'get_parent_until', 'get_code', + 'subscopes']: + raise AttributeError("Accessing %s of %s is not allowed." + % (self, name)) return getattr(self.func, name) def __repr__(self):