This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Joshua.Landau
Recipients Joshua.Landau
Date 2011-11-04.19:37:31
SpamBayes Score 3.8817575e-08
Marked as misclassified No
Message-id <1320435452.65.0.656040815575.issue13343@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-11-04 19:37:32Joshua.Landausetrecipients: + Joshua.Landau
2011-11-04 19:37:32Joshua.Landausetmessageid: <1320435452.65.0.656040815575.issue13343@psf.upfronthosting.co.za>
2011-11-04 19:37:32Joshua.Landaulinkissue13343 messages
2011-11-04 19:37:31Joshua.Landaucreate