Message200866
The bug is not in Idle. Its interpreter is a subclass of code.InteractiveInterpreter (II) and that (and its subclass InteractiveConsole) have the bug.
C:\Programs\Python33>python -m code
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> def a():
... def b():
... nonlocal c
File "<string>", line None
SyntaxError: no binding for nonlocal 'c' found
II.runsource compiles cumulative source with codeop.CommandCompile, which wraps codeop._maybe_compile. That returns None (source incomplete), raises (source complete but invalid), or return code (source complete and valid) to be executed. It mis-classifies the code in question.
>>> import codeop as op
>>> src = '''def a():
def b():
nonlocal c
'''
>>> op.CommandCompiler()(src)
Traceback (most recent call last):
...
SyntaxError: no binding for nonlocal 'c' found
PyShell.ModifiedInterpreter.runsource wraps II.runsource.
return InteractiveInterpreter.runsource(self, source, filename)
Someone needs to compare _maybe_compile to the equivalent C code used by the real interpreter. |
|
Date |
User |
Action |
Args |
2013-10-22 03:19:10 | terry.reedy | set | recipients:
+ terry.reedy, Rosuav |
2013-10-22 03:19:10 | terry.reedy | set | messageid: <1382411950.95.0.346182960493.issue19335@psf.upfronthosting.co.za> |
2013-10-22 03:19:10 | terry.reedy | link | issue19335 messages |
2013-10-22 03:19:10 | terry.reedy | create | |
|