Commit c6f29a39 authored by Stefan Behnel's avatar Stefan Behnel

push defaults-getter function into module scope instead of risking to make it a method

parent 3c461473
...@@ -8822,8 +8822,10 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin): ...@@ -8822,8 +8822,10 @@ class PyCFunctionNode(ExprNode, ModuleNameMixin):
self.pos, args=[defaults_tuple, defaults_kwdict])), self.pos, args=[defaults_tuple, defaults_kwdict])),
decorators=None, decorators=None,
name=StringEncoding.EncodedString("__defaults__")) name=StringEncoding.EncodedString("__defaults__"))
defaults_getter.analyse_declarations(env) # defaults getter must never live in class scopes, it's always a module function
defaults_getter = defaults_getter.analyse_expressions(env) module_scope = env.global_scope()
defaults_getter.analyse_declarations(module_scope)
defaults_getter = defaults_getter.analyse_expressions(module_scope)
defaults_getter.body = defaults_getter.body.analyse_expressions( defaults_getter.body = defaults_getter.body.analyse_expressions(
defaults_getter.local_scope) defaults_getter.local_scope)
defaults_getter.py_wrapper_required = False defaults_getter.py_wrapper_required = False
......
...@@ -3068,7 +3068,8 @@ class DefNode(FuncDefNode): ...@@ -3068,7 +3068,8 @@ class DefNode(FuncDefNode):
def generate_function_definitions(self, env, code): def generate_function_definitions(self, env, code):
if self.defaults_getter: if self.defaults_getter:
self.defaults_getter.generate_function_definitions(env, code) # defaults getter must never live in class scopes, it's always a module function
self.defaults_getter.generate_function_definitions(env.global_scope(), code)
# Before closure cnames are mangled # Before closure cnames are mangled
if self.py_wrapper_required: if self.py_wrapper_required:
......
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