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): ...@@ -2375,12 +2375,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.put_error_if_neg(self.pos, "__Pyx_init_sys_getdefaultencoding_params()") code.put_error_if_neg(self.pos, "__Pyx_init_sys_getdefaultencoding_params()")
code.putln("#endif") 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.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, env.module_cname,
__main__name.cname)) code.intern_identifier(EncodedString("__name__")),
code.intern_identifier(EncodedString("__main__"))))
code.putln("}") code.putln("}")
# set up __file__ and __path__, then add the module to sys.modules # set up __file__ and __path__, then add the module to sys.modules
......
...@@ -4908,9 +4908,9 @@ class CClassDefNode(ClassDefNode): ...@@ -4908,9 +4908,9 @@ class CClassDefNode(ClassDefNode):
# Cython (such as closures), the 'internal' # Cython (such as closures), the 'internal'
# directive is set by users # directive is set by users
code.putln( code.putln(
'if (PyObject_SetAttrString(%s, "%s", (PyObject *)&%s) < 0) %s' % ( 'if (PyObject_SetAttr(%s, %s, (PyObject *)&%s) < 0) %s' % (
Naming.module_cname, Naming.module_cname,
scope.class_name, code.intern_identifier(scope.class_name),
typeobj_cname, typeobj_cname,
code.error_goto(entry.pos))) code.error_goto(entry.pos)))
weakref_entry = scope.lookup_here("__weakref__") if not scope.is_closure_class_scope else None 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