1.1 --- a/common.py Sun Oct 23 14:54:04 2016 +0200
1.2 +++ b/common.py Sun Oct 23 14:56:33 2016 +0200
1.3 @@ -109,9 +109,16 @@
1.4 self.namespace_path = []
1.5 self.in_function = False
1.6
1.7 - # Attribute chains.
1.8 + # Retain the assignment value expression and track invocations.
1.9 +
1.10 + self.in_assignment = None
1.11 + self.in_invocation = False
1.12 +
1.13 + # Attribute chain state management.
1.14
1.15 self.attrs = []
1.16 + self.chain_assignment = []
1.17 + self.chain_invocation = []
1.18
1.19 def __repr__(self):
1.20 return "CommonModule(%r, %r)" % (self.name, self.importer)
1.21 @@ -580,17 +587,25 @@
1.22
1.23 return name_ref
1.24
1.25 + # Attribute chain handling.
1.26 +
1.27 def reset_attribute_chain(self):
1.28
1.29 "Reset the attribute chain for a subexpression of an attribute access."
1.30
1.31 self.attrs = []
1.32 + self.chain_assignment.append(self.in_assignment)
1.33 + self.chain_invocation.append(self.in_invocation)
1.34 + self.in_assignment = None
1.35 + self.in_invocation = False
1.36
1.37 def restore_attribute_chain(self, attrs):
1.38
1.39 "Restore the attribute chain for an attribute access."
1.40
1.41 self.attrs = attrs
1.42 + self.in_assignment = self.chain_assignment.pop()
1.43 + self.in_invocation = self.chain_invocation.pop()
1.44
1.45 def have_access_expression(self, node):
1.46