Author ncoghlan
Recipients Esa.Peuha, Mark.Shannon, Rosuav, ncoghlan, terry.reedy
Date 2013-10-22.12:38:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
As a potential fix (albeit an ugly hack), try changing this part of codeop._maybe_compile:

    if not code1 and repr(err1) == repr(err2):
        raise err1

To something like:

    if not code1 and repr(err1) == repr(err2):
        if isinstance(err1, SyntaxError) and "no binding for nonlocal" in str(err1) and not source.endswith("\n\n"):
            # Allow a nonlocal namebinding to be supplied *after* a
            # a function definition (the standard interpreter loop
            # handles this by blocking on stdin, but this module accepts
            # input as complete strings rather than as a stream)
            return None
        raise err1
Date User Action Args
2013-10-22 12:38:43ncoghlansetrecipients: + ncoghlan, terry.reedy, Mark.Shannon, Rosuav, Esa.Peuha
2013-10-22 12:38:43ncoghlansetmessageid: <>
2013-10-22 12:38:43ncoghlanlinkissue19335 messages
2013-10-22 12:38:42ncoghlancreate