Interactive shell imports from .

Issue #2934 new
Stefano Rivera
created an issue

Because of nested imports inside the the interactive console code, the import of the code module is done after has put . early in sys.path.

This means that if you have a in your current directory, with e.g. some Python3 code in it, print('a', end=' '), the REPL just crashes. (Debian #901753)

$ pypy
Python 2.7.13 (6.0.0+dfsg-3+b1, Oct 10 2018, 09:33:53)
[PyPy 6.0.0 with GCC 8.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "/usr/lib/pypy/lib_pypy/", line 42, in interactive_console
    run_multiline_interactive_console(mainmodule, future_flags=future_flags)
  File "/usr/lib/pypy/lib_pypy/pyrepl/", line 47, in run_multiline_interactive_console
    import code
  File "", line 1
    print('a', end='bar')
SyntaxError: invalid syntax (expected ')')

Comments (2)

  1. Carl Friedrich Bolz-Tereick

    The import behaviour is normal for Python, if you have local .py files with the name of stdlib modules, they will be picked up. What is different in PyPy is that the repl always uses the code stdlib module. If you have a around many things break in CPython too, such as importing pdb. So I am not sure we can easily change anything.

  2. Log in to comment