1.1 --- a/generator.py Sat Nov 26 18:05:47 2016 +0100
1.2 +++ b/generator.py Sat Nov 26 19:30:47 2016 +0100
1.3 @@ -804,8 +804,8 @@
1.4
1.5 if self.optimiser.constant_numbers.has_key(attr_path):
1.6 constant_number = self.optimiser.constant_numbers[attr_path]
1.7 - constant_value = "const%d" % constant_number
1.8 - return "{&%s, &%s} /* %s */" % (constant_value, constant_value, name)
1.9 + constant_value = "__const%d" % constant_number
1.10 + return "%s /* %s */" % (constant_value, name)
1.11
1.12 # Predefined constant references.
1.13
1.14 @@ -813,6 +813,16 @@
1.15 attr_path = encode_predefined_reference("%s.%s" % (path, name))
1.16 return "{&%s, &%s} /* %s */" % (attr_path, attr_path, name)
1.17
1.18 + # Special cases.
1.19 +
1.20 + if name == "__name__":
1.21 + local_number = self.importer.all_constants[path][path]
1.22 + constant_name = "$c%d" % local_number
1.23 + attr_path = "%s.%s" % (path, constant_name)
1.24 + constant_number = self.optimiser.constant_numbers[attr_path]
1.25 + constant_value = "__const%d" % constant_number
1.26 + return "%s /* %s */" % (constant_value, name)
1.27 +
1.28 # General undetermined members.
1.29
1.30 if kind in ("<var>", "<instance>"):