Code.py InteractiveConsole and the new repl

The new python interactive shell in 3.13 is great. However, both flask shell and Django’s python manage.py shell commands use code.py’s InteractiveConsole which is described as:

Closely emulate the behavior of the interactive Python interpreter.

So I would have expected this to be the new ‘fancy’ interactive shell on python 3.13. But it’s not. Am I wrong to have expected InteractiveConsole to be using the new fancy console when available? If not, for people that want to integrate a ‘fancy’ console like Flask or Django, how should that be handled? If InteractiveConsole is only expected to be the ‘old’ shell I think at least this should be part of the documentation.

1 Like

It’s already fixed, see Python 3.13.0 REPL loads local files unexpectedly, causing conflicts and security issues · Issue #125140 · python/cpython (github.com)

Why would that fix the issue? That has to do with handling of sys.path, I can’t really see how that would change the behavior of InteractiveConsole

Oh, I’m sorry, I miss read your description.

1 Like

Yeah, I think that it’s just a documentation issue.

You should use _pyrepl if you want to have the same new REPL, but it’s a private module. So I’m not sure if it’s a good idea to rely on its API now.

1 Like

Indeed is not. Right now the priority is making this stable and for that we may (and we are) need to change a lot of APIs and restructure this all the time so we are not ready to expose anything. Maybe this is something we can do in the future.

3 Likes

Would you like to file a documentation PR to reflect this? Otherwise me or @ambv can do it