1.1 --- a/common.py Wed Oct 19 16:37:01 2016 +0200
1.2 +++ b/common.py Wed Oct 19 21:05:24 2016 +0200
1.3 @@ -559,7 +559,7 @@
1.4 # Break attribute chains where non-access nodes are found.
1.5
1.6 if not self.have_access_expression(n):
1.7 - self.attrs = []
1.8 + self.reset_attribute_chain()
1.9
1.10 # Descend into the expression, extending backwards any existing chain,
1.11 # or building another for the expression.
1.12 @@ -568,7 +568,8 @@
1.13
1.14 # Restore chain information applying to this node.
1.15
1.16 - self.attrs = attrs
1.17 + if not self.have_access_expression(n):
1.18 + self.restore_attribute_chain(attrs)
1.19
1.20 # Return immediately if the expression was another access and thus a
1.21 # continuation backwards along the chain. The above processing will
1.22 @@ -579,6 +580,18 @@
1.23
1.24 return name_ref
1.25
1.26 + def reset_attribute_chain(self):
1.27 +
1.28 + "Reset the attribute chain for a subexpression of an attribute access."
1.29 +
1.30 + self.attrs = []
1.31 +
1.32 + def restore_attribute_chain(self, attrs):
1.33 +
1.34 + "Restore the attribute chain for an attribute access."
1.35 +
1.36 + self.attrs = attrs
1.37 +
1.38 def have_access_expression(self, node):
1.39
1.40 "Return whether the expression associated with 'node' is Getattr."