# HG changeset patch # User Paul Boddie # Date 1481233832 -3600 # Node ID f10a63ef3712812153e2a9bb1d789142eed5f406 # Parent 17317598efd2909187e69b1a564264d25c32f30d Prevent multiple static definitions with the same location. diff -r 17317598efd2 -r f10a63ef3712 inspector.py --- a/inspector.py Thu Dec 08 21:45:09 2016 +0100 +++ b/inspector.py Thu Dec 08 22:50:32 2016 +0100 @@ -495,11 +495,18 @@ else: bases.append(base_class) + # Detect conflicting definitions. Such definitions cause conflicts in + # the storage of namespace-related information. + + class_name = self.get_object_path(n.name) + ref = self.get_object(class_name) + + if ref.static(): + raise InspectError("Multiple definitions for the same name are not permitted.", class_name, n) + # Record bases for the class and retain the class name. # Note that the function class does not inherit from the object class. - class_name = self.get_object_path(n.name) - if not bases and class_name != "__builtins__.core.object" and \ class_name != "__builtins__.core.function": @@ -577,9 +584,17 @@ else: original_name = None + # Detect conflicting definitions. Such definitions cause conflicts in + # the storage of namespace-related information. + + function_name = self.get_object_path(name) + ref = self.get_object(function_name) + + if ref.static(): + raise InspectError("Multiple definitions for the same name are not permitted.", function_name, n) + # Initialise argument and local records. - function_name = self.get_object_path(name) argnames = get_argnames(n.argnames) is_method = self.in_class and not self.in_function