Print during import screws up input prompt #10113

Closed
vidartf opened this Issue Jan 2, 2017 · 2 comments

Projects

None yet

3 participants

@vidartf
vidartf commented Jan 2, 2017 edited

Steps to reproduce:

  1. Create a module which prints something during import, e.g. a file hello_world.py:
print('Hello world!')
  1. Try to use tab-completion for sub-modules in an import statement
In [1]: import hello_world.<hit tab>

For this minimal example there wouldn't be any submodules, but it will autocomplete py to match the filename. What happens is that the print statement during import interferes with the input prompt.

Example output:

>ipython
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import hello_world.Hello world!
py
@vidartf
vidartf commented Jan 2, 2017

Note: After the tab completion, the cursor will be on the wrong line (at least for Windows' cmd terminal).

@minrk minrk added the tab-completion label Jan 2, 2017
@takluyver takluyver added a commit to takluyver/ipython that referenced this issue Jan 13, 2017
@takluyver takluyver Use prompt_toolkit's patch_stdout_context when finding completions
Closes gh-10113
ca20895
@takluyver takluyver added this to the 5.2 milestone Jan 13, 2017
@takluyver
Member

See #10153

@minrk minrk closed this in #10153 Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment