Nick Coghlan added the comment: 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 ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19335> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com