[IPython-dev] Raising a SyntaxError in InputTransformer

Volker Braun vbraun.name at gmail.com
Fri Aug 9 11:07:35 EDT 2013

I posted recently on this subject but didn't get any reply. Maybe I wasn't
clear enough, so let me try again: Its great that IPython now has a nice
framework for transforming input before passing it off to Python. But that
also means that there must be a way to hand syntax errors back to the user.
One could just not apply the input transformation, but then that would
result in a very confusing error message. The Python interpreter obviously
does not understand the un-transformed input, that is the whole point of the
input transformation.

In particular, Sage supports Magma-syntax to create new rings:

sage: R.<x> = QQ[]

Now if there are unbalanced brackets ("QQ[}") then we would like to tell the
user that, but right now any exceptions raised by the input transformer will
not be caught and terminate IPython. I think it would be easy to patch
IPython to catch SyntaxErrors from the input transformers, but then I was
hoping that the developers would have already made some sort of plan for how
to notify the user of syntax errors. Or maybe it is not desirable for some


PS: I just tested this with IPython-1.0.0, didn't work with older versions

View this message in context: http://python.6.x6.nabble.com/Raising-a-SyntaxError-in-InputTransformer-tp5027773.html
Sent from the IPython - Development mailing list archive at Nabble.com.

More information about the IPython-dev mailing list