1.1 --- a/common.py Tue Jan 24 17:20:35 2017 +0100
1.2 +++ b/common.py Tue Jan 24 19:10:31 2017 +0100
1.3 @@ -4,7 +4,7 @@
1.4 Common functions.
1.5
1.6 Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013,
1.7 - 2014, 2015, 2016 Paul Boddie <paul@boddie.org.uk>
1.8 + 2014, 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -394,16 +394,9 @@
1.13
1.14 name_ref = self.process_structure_node(expr)
1.15
1.16 - # Either unpack the items and present them directly to each assignment
1.17 - # node.
1.18 + # Have the assignment nodes access each item via the sequence API.
1.19
1.20 - if isinstance(name_ref, LiteralSequenceRef):
1.21 - self.process_literal_sequence_items(n, name_ref)
1.22 -
1.23 - # Or have the assignment nodes access each item via the sequence API.
1.24 -
1.25 - else:
1.26 - self.process_assignment_node_items_by_position(n, expr, name_ref)
1.27 + self.process_assignment_node_items_by_position(n, expr, name_ref)
1.28
1.29 def process_assignment_node_items_by_position(self, n, expr, name_ref):
1.30
1.31 @@ -417,8 +410,14 @@
1.32
1.33 assignments = []
1.34
1.35 - if isinstance(name_ref, NameRef):
1.36 + # Employ existing names to access the sequence.
1.37 + # Literal sequences do not provide names of accessible objects.
1.38 +
1.39 + if isinstance(name_ref, NameRef) and not isinstance(name_ref, LiteralSequenceRef):
1.40 temp = name_ref.name
1.41 +
1.42 + # For other expressions, create a temporary name to reference the items.
1.43 +
1.44 else:
1.45 temp = self.get_temporary_name()
1.46 self.next_temporary()
1.47 @@ -427,6 +426,8 @@
1.48 compiler.ast.Assign([compiler.ast.AssName(temp, "OP_ASSIGN")], expr)
1.49 )
1.50
1.51 + # Assign the items to the target nodes.
1.52 +
1.53 for i, node in enumerate(n.nodes):
1.54 assignments.append(
1.55 compiler.ast.Assign([node], compiler.ast.Subscript(