This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pablogsal
Recipients BTaskaya, lys.nikolaou, pablogsal, terry.reedy, tusharsadhwani
Date 2022-01-29.17:41:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1643478065.25.0.100546616158.issue46521@roundup.psfhosted.org>
In-reply-to
Content
>> 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
History
Date User Action Args
2022-01-29 17:41:05pablogsalsetrecipients: + pablogsal, terry.reedy, lys.nikolaou, BTaskaya, tusharsadhwani
2022-01-29 17:41:05pablogsalsetmessageid: <1643478065.25.0.100546616158.issue46521@roundup.psfhosted.org>
2022-01-29 17:41:05pablogsallinkissue46521 messages
2022-01-29 17:41:05pablogsalcreate