Pablo Galindo Salgado <pablog...@gmail.com> added the comment:

>> Pablo, is there any possibility that the internal REPL parser could be 
>> wrapped, exposed to Python, and called with fake stdin/out/err objects?

I would really advise against this. Unfortunately, the state of affairs is that 
the REPL is somehow super entangled with the parser, to the point that is the 
tokenizer asking for more characters that triggers a read from stdin. Exposing 
this with some API would be super dangerous because we would be elevated to the 
"supported" level anything that works just because it happens to be close to 
what the interactive mode needs.

On the other side, codeop is fundamentally flawed in the way is built because 
relies on comparing error messages from the parser, which is a very poor way of 
handling semantic information.

What we need here is a mode of the parser that somehow raises a very specific 
error on incomplete input, but not an incorrect one. And that may be not 
immediate to implement given in how many places we can raise lexer and parser 
errors. I will give it a go, in any case

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46521>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to