Message147026
When setting defaults to keyword-only arguments in lambdas which are inside non-global scopes, cPython doesn't push the name to it's closure's co_freevars.
EXAMPLE:
global_variable = None
(lambda: (lambda *, keyword_only=global_variable: None))()
Because the inner lambda hasn't told the outer lambda to put global_variable in co_freevars, it fails to create the default to keyword_only. This only happens if the inner function is a lambda and you are setting a keyword_only variable.
It does not cause a crash if global_variable is local to the outer lambda, as the opcode LOAD_FAST is still created properly (as opposed to LOAD_NAME).
It does not crash if global_variable is used elsewhere in the outer function as co_freevars will be updated with it, allowing LOAD_NAME to retrieve it.
I've never done a bug here before and I'm unsure what to say, so please be nice and correct me if I'm doing it wrong. |
|
Date |
User |
Action |
Args |
2011-11-04 19:37:32 | Joshua.Landau | set | recipients:
+ Joshua.Landau |
2011-11-04 19:37:32 | Joshua.Landau | set | messageid: <1320435452.65.0.656040815575.issue13343@psf.upfronthosting.co.za> |
2011-11-04 19:37:32 | Joshua.Landau | link | issue13343 messages |
2011-11-04 19:37:31 | Joshua.Landau | create | |
|