Commit 0d37e44c authored by Stefan Behnel's avatar Stefan Behnel

Intern some identifier names that are likely to be otherwise interned anyway.

parent b5bafb96
......@@ -2375,12 +2375,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.put_error_if_neg(self.pos, "__Pyx_init_sys_getdefaultencoding_params()")
code.putln("#endif")
__main__name = code.globalstate.get_py_string_const(
EncodedString("__main__"), identifier=True)
code.putln("if (%s%s) {" % (Naming.module_is_main, self.full_module_name.replace('.', '__')))
code.put_error_if_neg(self.pos, 'PyObject_SetAttrString(%s, "__name__", %s)' % (
code.put_error_if_neg(self.pos, 'PyObject_SetAttr(%s, %s, %s)' % (
env.module_cname,
__main__name.cname))
code.intern_identifier(EncodedString("__name__")),
code.intern_identifier(EncodedString("__main__"))))
code.putln("}")
# set up __file__ and __path__, then add the module to sys.modules
......
......@@ -4908,9 +4908,9 @@ class CClassDefNode(ClassDefNode):
# Cython (such as closures), the 'internal'
# directive is set by users
code.putln(
'if (PyObject_SetAttrString(%s, "%s", (PyObject *)&%s) < 0) %s' % (
'if (PyObject_SetAttr(%s, %s, (PyObject *)&%s) < 0) %s' % (
Naming.module_cname,
scope.class_name,
code.intern_identifier(scope.class_name),
typeobj_cname,
code.error_goto(entry.pos)))
weakref_entry = scope.lookup_here("__weakref__") if not scope.is_closure_class_scope else None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment