You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a behaviour that is also quite used in a data science way, to run code within for loops for instance, which works well in Spyder, or iPython consoles in general. Running a line of code that has indentation should be possible when there is only one line (or several with same indentation).
Could eventually be integrated along #169 ?
Environment data
VS Code version: 1.26.1
Python-vscode: 2018.8.0
Linux Mint 18.1
Anaconda Python 3.6
virtual environment used: conda
iPython 6.4.0
Actual behavior
When running command "Run Selection/Line" with iPython interpreter on a line with indentation, it throws an error and iPython is closed...
Though, this works as I expect with Python interpeter when run inside an ipython terminal (my usual workaround anyway), that is: it runs the line (the string sent to the terminal will contain spaces before the text but the command runs without error). However, this contains error in the Console from developer tools (ses below).
Here is a gif showing the whole behaviour (Note: on the GIF, I am under another conda environment, Python 2.7 and Ipython 5.1.0 but I get exactly the same behaviour/error logs):
Expected behavior
To run the selected line
Steps to reproduce:
Set interpreter (settings python.pythonPath) to ipython
"Run Selection/Line in Python Terminal" on a line with indentation
Logs
Traceback within Python terminal (running iPython, when iPython is the set interpreter for the extension):
Traceback (most recent call last):
File "/home/hugo/anaconda2/envs/py36/bin/ipython", line 11, in<module>sys.exit(start_ipython())
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/IPython/__init__.py", line 125, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/IPython/terminal/ipapp.py", line 356, in start
self.shell.mainloop()
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 485, in mainloop
self.interact()
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 468, in interact
code = self.prompt_for_code()
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 381, in prompt_for_code
pre_run=self.pre_prompt, reset_current_buffer=True)
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/interface.py", line 415, in run
self.eventloop.run(self.input, self.create_eventloop_callbacks())
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/eventloop/posix.py", line 159, in run
t()
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/eventloop/posix.py", line 82, in read_from_stdin
inputstream.feed(data)
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/terminal/vt100_input.py", line 398, in feed
self._input_parser.send(c)
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/terminal/vt100_input.py", line 307, in _input_parser_generator
self._call_handler(match, prefix)
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/terminal/vt100_input.py", line 340, in _call_handler
self.feed_key_callback(KeyPress(key, insert_text))
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/interface.py", line 1048, in feed_key
cli.input_processor.process_keys()
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/key_binding/input_processor.py", line 219, in process_keys
self._process_coroutine.send(key_press)
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/key_binding/input_processor.py", line 176, in _process
self._call_handler(matches[-1], key_sequence=buffer[:])
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/key_binding/input_processor.py", line 247, in _call_handler
handler.call(event)
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/key_binding/registry.py", line 61, in call
return self.handler(event)
File "/home/hugo/anaconda2/envs/py36/lib/python3.6/site-packages/prompt_toolkit/key_binding/bindings/basic.py", line 280, in _
mouse_event, x, y = map(int, data[:-1].split(';'))
ValueError: not enough values to unpack (expected 3, got 2)
If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at [email protected]
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True
In Output:
None
Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)
None!
Interestingly, with the python interpreter, it does throw an error but the execution within an ipython terminal (sent as a python command) works!
(indeed in a python terminal having spaces before text throws an IndentationError but not in iPython....)
The text was updated successfully, but these errors were encountered:
Please note, the line is being executed. So the expected behavior is met.
The problem is you are trying to execute some invalid code.
I.e. The extension will not strip leading spaces, as we're not aware of the context of the code in the terminal.
To get around this, you'd have to select the necessary code.
Sure, the code is invalid for python (e.g. in a python prompt). But I mentionned this because the iPython console does execute the same code (the print(a), with 4 leading spaces) without error (e.g. by copy pasting the exact same string into the console it is fine) though if I select it with the leading spaces and use the extension command, it fails. So I guess it is related to the extension, not to iPython internal behaviour, that is why I am reporting it. If the expected behaviour is to execute pure python code then I understand it is not a real issue, though it would be nice to integrate the features offered by the iPython console when using it.
PS: Actually I just tested on Windows (Win 10, Anaconda Python 3.6, ipython 6.52.1, VScode 1.27.1, python extension 2018.8.0) and the same settings and actions gives the following string passed as a command into the ipython terminal (run inside a PowerShell):
With an extra blank line left, such that the code is not executed yet, and once executed simply gives a SyntaxError (which is not even clear about the original Python's IndentationError).
lockbot
locked as resolved and limited conversation to collaborators
Oct 5, 2018
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This is a behaviour that is also quite used in a data science way, to run code within for loops for instance, which works well in Spyder, or iPython consoles in general. Running a line of code that has indentation should be possible when there is only one line (or several with same indentation).
Could eventually be integrated along #169 ?
Environment data
Actual behavior
When running command "Run Selection/Line" with iPython interpreter on a line with indentation, it throws an error and iPython is closed...
Though, this works as I expect with Python interpeter when run inside an ipython terminal (my usual workaround anyway), that is: it runs the line (the string sent to the terminal will contain spaces before the text but the command runs without error). However, this contains error in the
Console
from developer tools (ses below).Here is a gif showing the whole behaviour (Note: on the GIF, I am under another conda environment, Python 2.7 and Ipython 5.1.0 but I get exactly the same behaviour/error logs):

Expected behavior
To run the selected line
Steps to reproduce:
python.pythonPath
) to ipythonLogs
Traceback within Python terminal (running iPython, when iPython is the set interpreter for the extension):
In Output:
None
Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
)None!
Interestingly, with the python interpreter, it does throw an error but the execution within an ipython terminal (sent as a python command) works!
(indeed in a python terminal having spaces before text throws an
IndentationError
but not in iPython....)The text was updated successfully, but these errors were encountered: