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 <1382445523.13.0.876229889389.issue19335@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2013-10-22 12:38:43ncoghlansetrecipients: + ncoghlan, terry.reedy, Mark.Shannon, Rosuav, Esa.Peuha
2013-10-22 12:38:43ncoghlansetmessageid: <1382445523.13.0.876229889389.issue19335@psf.upfronthosting.co.za>
2013-10-22 12:38:43ncoghlanlinkissue19335 messages
2013-10-22 12:38:42ncoghlancreate