Closed sapi closed 9 years ago
That one took a bit to track down. I'd be curious about why (if?) it worked on your system, and if so, what the difference between our configurations is.
Certainly on any sane system this should be the expected output:
In [1]: import builtins
In [2]: builtins is globals()['__builtins__']
Out[2]: True
But it certainly didn't click for me until I stared at the traceback for a little while.
Oh, and probably worth mentioning here just so it's documented somewhere (I forgot to put it in a comment) -- I changed redirect_input_prompt
to require either gbls['input']
or gbls['__builtins__']
.
As we're using a globals dict returned from exec
, the latter is actually guaranteed.
Found the cause.
I run scripts from the shell (ipython) to get nicer tracebacks. Something about that triggers the builtins optimisation; I can't reproduce it when running MyPyTutor.py with python directly.
Oh well. It's probably a good thing to have fixed anyway.
Attempting to redirect the input prompt causes a RuntimeError (recursion depth exceeded).
Steps to reproduce:
raise exception
after this line so that you see the full traceback for the first errorinput
Steps to fix/hide:
input
This is reproducible in 0065c9c6596ba9a24e9be8f66feaaaa2713d0d6c, the last commit before I merged the ui branch, so it's not that.
@jgat You may be interested in this one.
(Incidentally, you can assume that
lcls
is always a globals dict. It needs to be;exec
fails spectacularly if given separate dicts. I agree the naming is stupid; I forgot to update it when I fixed theexec
bugs, but will try to do so soon.)