inspector.py | raw changeset files shortlog |
1.1 --- a/inspector.py Thu Sep 22 22:08:37 2016 +0200 1.2 +++ b/inspector.py Thu Sep 22 22:15:50 2016 +0200 1.3 @@ -776,6 +776,11 @@ 1.4 self.set_special(n.name, value) 1.5 return value 1.6 1.7 + # Test for self usage, which is only allowed in methods. 1.8 + 1.9 + if n.name == "self" and not (self.in_function and self.in_class): 1.10 + raise InspectError("Use of self is only allowed in methods.", path, n) 1.11 + 1.12 # Record usage of the name. 1.13 1.14 self.record_name(n.name)