s.error("Expected an identifier before '='",
pos = arg.pos)
encoded_name = Utils.EncodedString(arg.name)
- keyword = ExprNodes.KeywordNameNode(arg.pos,
+ keyword = ExprNodes.IdentifierStringNode(arg.pos,
value = encoded_name)
arg = p_simple_expr(s)
keyword_args.append((keyword, arg))
lhs = ExprNodes.NameNode(pos,
name = as_name or target_name),
rhs = ExprNodes.ImportNode(pos,
- module_name = ExprNodes.StringNode(pos,
- value = dotted_name),
+ module_name = ExprNodes.IdentifierStringNode(
+ pos, value = dotted_name),
name_list = name_list))
stats.append(stat)
return Nodes.StatListNode(pos, stats = stats)
items = []
for (name_pos, name, as_name) in imported_names:
encoded_name = Utils.EncodedString(name)
- encoded_name.encoding = s.source_encoding
imported_name_strings.append(
- ExprNodes.StringNode(name_pos, value = encoded_name))
+ ExprNodes.IdentifierStringNode(name_pos, value = encoded_name))
items.append(
(name,
ExprNodes.NameNode(name_pos,
import_list = ExprNodes.ListNode(
imported_names[0][0], args = imported_name_strings)
dotted_name = Utils.EncodedString(dotted_name)
- dotted_name.encoding = s.source_encoding
return Nodes.FromImportStatNode(pos,
module = ExprNodes.ImportNode(dotted_name_pos,
- module_name = ExprNodes.StringNode(dotted_name_pos,
- value = dotted_name),
+ module_name = ExprNodes.IdentifierStringNode(pos, value = dotted_name),
name_list = import_list),
items = items)
string_map[value] = entry
return entry
- def add_py_string(self, entry):
+ def add_py_string(self, entry, identifier = None):
# If not already done, allocate a C name for a Python version of
# a string literal, and add it to the list of Python strings to
# be created at module init time. If the string resembles a
entry.pystring_cname = entry.cname + "p"
self.pystring_entries.append(entry)
self.global_scope().all_pystring_entries.append(entry)
- if possible_identifier(value):
+ if identifier or (identifier is None and possible_identifier(value)):
entry.is_interned = 1
self.global_scope().new_interned_string_entries.append(entry)
def intern_identifier(self, name):
string_entry = self.get_string_const(name, identifier = True)
- self.add_py_string(string_entry)
+ self.add_py_string(string_entry, identifier = 1)
return string_entry.pystring_cname
def find_module(self, module_name, pos):