2016-09-22 | Paul Boddie | raw files shortlog changelog graph | Forbid assignment to self. | |
inspector.py (file) |
1.1 --- a/inspector.py Thu Sep 22 22:15:50 2016 +0200 1.2 +++ b/inspector.py Thu Sep 22 22:20:41 2016 +0200 1.3 @@ -325,6 +325,8 @@ 1.4 # Names and attributes are assigned the entire expression. 1.5 1.6 if isinstance(n, compiler.ast.AssName): 1.7 + if n.name == "self": 1.8 + raise InspectError("Redefinition of self is not allowed.", self.get_namespace_path(), n) 1.9 1.10 name_ref = expr and self.process_structure_node(expr) 1.11