1.1 --- a/deducer.py Wed Oct 19 21:06:42 2016 +0200
1.2 +++ b/deducer.py Wed Oct 19 22:16:27 2016 +0200
1.3 @@ -791,29 +791,42 @@
1.4 # For each combination of name and attribute names, obtain
1.5 # applicable modifiers.
1.6
1.7 - for (name, attrnames), modifiers in all_accesses.items():
1.8 + for (name, attrname_str), modifiers in all_accesses.items():
1.9
1.10 # For each access, determine the name versions affected by
1.11 # assignments.
1.12
1.13 for access_number, assignment in enumerate(modifiers):
1.14 + if not assignment:
1.15 + continue
1.16 +
1.17 if name:
1.18 - access_location = (path, name, attrnames, access_number)
1.19 + access_location = (path, name, attrname_str, access_number)
1.20 else:
1.21 - access_location = (path, None, attrnames, 0)
1.22 -
1.23 - if assignment:
1.24 - self.reference_assignments.add(access_location)
1.25 + access_location = (path, None, attrname_str, 0)
1.26 +
1.27 + self.reference_assignments.add(access_location)
1.28
1.29 # Associate assignments with usage.
1.30
1.31 - accessor_locations = self.get_accessors_for_access(access_location)
1.32 -
1.33 - for location in accessor_locations:
1.34 - for usage in self.location_index[location]:
1.35 - if assignment:
1.36 + attrnames = get_attrnames(attrname_str)
1.37 +
1.38 + # Assignment occurs for the only attribute.
1.39 +
1.40 + if len(attrnames) == 1:
1.41 + accessor_locations = self.get_accessors_for_access(access_location)
1.42 +
1.43 + for location in accessor_locations:
1.44 + for usage in self.location_index[location]:
1.45 init_item(self.assigned_attrs, usage, set)
1.46 - self.assigned_attrs[usage].add((path, name, attrnames))
1.47 + self.assigned_attrs[usage].add((path, name, attrnames[0]))
1.48 +
1.49 + # Assignment occurs for the final attribute.
1.50 +
1.51 + else:
1.52 + usage = ((attrnames[-1], False, False),)
1.53 + init_item(self.assigned_attrs, usage, set)
1.54 + self.assigned_attrs[usage].add((path, name, attrnames[-1]))
1.55
1.56 def init_aliases(self):
1.57
1.58 @@ -899,7 +912,7 @@
1.59 if not usage:
1.60 continue
1.61
1.62 - for path, name, attrnames in all_attrnames:
1.63 + for path, name, attrname in all_attrnames:
1.64 class_types = self.get_class_types_for_usage(usage)
1.65 only_instance_types = set(self.get_instance_types_for_usage(usage)).difference(class_types)
1.66 module_types = self.get_module_types_for_usage(usage)
1.67 @@ -912,14 +925,14 @@
1.68 class_types, only_instance_types, module_types, constrained = t
1.69 objects = set(class_types).union(only_instance_types).union(module_types)
1.70
1.71 - self.mutate_attribute(objects, attrnames)
1.72 -
1.73 - def mutate_attribute(self, objects, attrnames):
1.74 -
1.75 - "Mutate static 'objects' with the given 'attrnames'."
1.76 + self.mutate_attribute(objects, attrname)
1.77 +
1.78 + def mutate_attribute(self, objects, attrname):
1.79 +
1.80 + "Mutate static 'objects' with the given 'attrname'."
1.81
1.82 for name in objects:
1.83 - attr = "%s.%s" % (name, attrnames)
1.84 + attr = "%s.%s" % (name, attrname)
1.85 value = self.importer.get_object(attr)
1.86
1.87 # If the value is None, the attribute is