Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Selection/Line and Run File produce error when used consecutively #2997

Open
AbhinavAjitsaria opened this issue Oct 24, 2018 · 2 comments
Labels
area-editor-* User-facing catch-all area-repl feature-request Request for new features or functionality needs proposal Need to make some design decisions

Comments

@AbhinavAjitsaria
Copy link

Environment data

  • VS Code version: 1.28.2
  • Extension version: 2018.9.1
  • OS and version: Ubuntu 18.04
  • Python version: 3.6.6
  • Type of virtual environment used : venv

Actual behavior

  • After 'Run Selection/Line in Python terminal' once, if 'Run Python File in terminal' is used, the command tries to execute in the ongoing interpreter session invoked by the first 'Run'

  • After 'Run File in Python terminal' once, if 'Run Selection/Line in terminal' is used, the command tries to execute in the open shell session invoked by the first 'Run' directly without invoking the interpreter first

Expected behavior

  • Run Selection/Line in Python terminal should invoke the Python interpreter first if the terminal is open and its state has changed since last Run.
  • Run python file in terminal should close Python interpreter if it is currently open

Steps to reproduce:

  1. Write a basic python program and Run Selection/Line in Terrminal.
  2. Immediately after Step 1, Run File in Terminal.
    The options can be done in reverse order too. It produces and error too.

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

bootstrap-window.js:195 [uncaught exception]: TypeError: Cannot read property 'isWrapped' of undefined
onUnexpectedError @ bootstrap-window.js:195
(anonymous) @ bootstrap-window.js:38
emitOne @ events.js:116
emit @ events.js:211
window.onerror @ /usr/share/code/resources/electron.asar/renderer/init.js:147
i.globals.onerror @ workbench.main.js:sourcemap:1538
setTimeout (async)
Linkifier.linkifyRows @ Linkifier.ts:76
Terminal._queueLinkification @ Terminal.ts:1143
(anonymous) @ Terminal.ts:619
EventEmitter.emit @ EventEmitter.ts:74
Renderer._renderRows @ Renderer.ts:199
RenderDebouncer._innerRefresh @ RenderDebouncer.ts:49
(anonymous) @ RenderDebouncer.ts:40
requestAnimationFrame (async)
RenderDebouncer.refresh @ RenderDebouncer.ts:40
Renderer.refreshRows @ Renderer.ts:190
Terminal.refresh @ Terminal.ts:1132
Renderer.onIntersectionChange @ Renderer.ts:87
t._resize @ workbench.main.js:sourcemap:3549
t.layout @ workbench.main.js:sourcemap:3548
t.setVisible @ workbench.main.js:sourcemap:3542
(anonymous) @ workbench.main.js:sourcemap:3641
t.setVisible @ workbench.main.js:sourcemap:3641
(anonymous) @ workbench.main.js:sourcemap:3648
e.setActiveInstanceByIndex @ workbench.main.js:sourcemap:3648
e.setActiveInstance @ workbench.main.js:sourcemap:3647
e.$show @ workbench.main.js:sourcemap:3251
t._doInvokeHandler @ workbench.main.js:sourcemap:3267
t._invokeHandler @ workbench.main.js:sourcemap:3266
t._receiveRequest @ workbench.main.js:sourcemap:3265
t._receiveOneMessage @ workbench.main.js:sourcemap:3264
(anonymous) @ workbench.main.js:sourcemap:3262
e.fire @ workbench.main.js:sourcemap:181
a @ workbench.main.js:sourcemap:318
n._socketDataListener @ workbench.main.js:sourcemap:318
emitOne @ events.js:116
emit @ events.js:211
addChunk @ _stream_readable.js:263
readableAddChunk @ _stream_readable.js:250
Readable.push @ _stream_readable.js:208
onread @ net.js:594
bootstrap-window.js:198 TypeError: Cannot read property 'isWrapped' of undefined
    at Buffer.getWrappedRangeForLine (Buffer.ts:302)
    at BufferStringIterator.next (Buffer.ts:421)
    at Linkifier._linkifyRows (Linkifier.ts:101)
    at Linkifier.ts:76
onUnexpectedError @ bootstrap-window.js:198
(anonymous) @ bootstrap-window.js:38
emitOne @ events.js:116
emit @ events.js:211
window.onerror @ /usr/share/code/resources/electron.asar/renderer/init.js:147
i.globals.onerror @ workbench.main.js:sourcemap:1538
setTimeout (async)
Linkifier.linkifyRows @ Linkifier.ts:76
Terminal._queueLinkification @ Terminal.ts:1143
(anonymous) @ Terminal.ts:619
EventEmitter.emit @ EventEmitter.ts:74
Renderer._renderRows @ Renderer.ts:199
RenderDebouncer._innerRefresh @ RenderDebouncer.ts:49
(anonymous) @ RenderDebouncer.ts:40
requestAnimationFrame (async)
RenderDebouncer.refresh @ RenderDebouncer.ts:40
Renderer.refreshRows @ Renderer.ts:190
Terminal.refresh @ Terminal.ts:1132
Renderer.onIntersectionChange @ Renderer.ts:87
t._resize @ workbench.main.js:sourcemap:3549
t.layout @ workbench.main.js:sourcemap:3548
t.setVisible @ workbench.main.js:sourcemap:3542
(anonymous) @ workbench.main.js:sourcemap:3641
t.setVisible @ workbench.main.js:sourcemap:3641
(anonymous) @ workbench.main.js:sourcemap:3648
e.setActiveInstanceByIndex @ workbench.main.js:sourcemap:3648
e.setActiveInstance @ workbench.main.js:sourcemap:3647
e.$show @ workbench.main.js:sourcemap:3251
t._doInvokeHandler @ workbench.main.js:sourcemap:3267
t._invokeHandler @ workbench.main.js:sourcemap:3266
t._receiveRequest @ workbench.main.js:sourcemap:3265
t._receiveOneMessage @ workbench.main.js:sourcemap:3264
(anonymous) @ workbench.main.js:sourcemap:3262
e.fire @ workbench.main.js:sourcemap:181
a @ workbench.main.js:sourcemap:318
n._socketDataListener @ workbench.main.js:sourcemap:318
emitOne @ events.js:116
emit @ events.js:211
addChunk @ _stream_readable.js:263
readableAddChunk @ _stream_readable.js:250
Readable.push @ _stream_readable.js:208
onread @ net.js:594
Buffer.ts:302 Uncaught TypeError: Cannot read property 'isWrapped' of undefined
    at Buffer.getWrappedRangeForLine (Buffer.ts:302)
    at BufferStringIterator.next (Buffer.ts:421)
    at Linkifier._linkifyRows (Linkifier.ts:101)
    at Linkifier.ts:76
Buffer.getWrappedRangeForLine @ Buffer.ts:302
BufferStringIterator.next @ Buffer.ts:421
Linkifier._linkifyRows @ Linkifier.ts:101
(anonymous) @ Linkifier.ts:76
setTimeout (async)
Linkifier.linkifyRows @ Linkifier.ts:76
Terminal._queueLinkification @ Terminal.ts:1143
(anonymous) @ Terminal.ts:619
EventEmitter.emit @ EventEmitter.ts:74
Renderer._renderRows @ Renderer.ts:199
RenderDebouncer._innerRefresh @ RenderDebouncer.ts:49
(anonymous) @ RenderDebouncer.ts:40
requestAnimationFrame (async)
RenderDebouncer.refresh @ RenderDebouncer.ts:40
Renderer.refreshRows @ Renderer.ts:190
Terminal.refresh @ Terminal.ts:1132
Renderer.onIntersectionChange @ Renderer.ts:87
t._resize @ workbench.main.js:sourcemap:3549
t.layout @ workbench.main.js:sourcemap:3548
t.setVisible @ workbench.main.js:sourcemap:3542
(anonymous) @ workbench.main.js:sourcemap:3641
t.setVisible @ workbench.main.js:sourcemap:3641
(anonymous) @ workbench.main.js:sourcemap:3648
e.setActiveInstanceByIndex @ workbench.main.js:sourcemap:3648
e.setActiveInstance @ workbench.main.js:sourcemap:3647
e.$show @ workbench.main.js:sourcemap:3251
t._doInvokeHandler @ workbench.main.js:sourcemap:3267
t._invokeHandler @ workbench.main.js:sourcemap:3266
t._receiveRequest @ workbench.main.js:sourcemap:3265
t._receiveOneMessage @ workbench.main.js:sourcemap:3264
(anonymous) @ workbench.main.js:sourcemap:3262
e.fire @ workbench.main.js:sourcemap:181
a @ workbench.main.js:sourcemap:318
n._socketDataListener @ workbench.main.js:sourcemap:318
emitOne @ events.js:116
emit @ events.js:211
addChunk @ _stream_readable.js:263
readableAddChunk @ _stream_readable.js:250
Readable.push @ _stream_readable.js:208
onread @ net.js:594
@brettcannon brettcannon self-assigned this Oct 25, 2018
@brettcannon brettcannon added triage bug Issue identified by VS Code Team member as probable bug area-terminal and removed triage labels Oct 25, 2018
@brettcannon brettcannon removed their assignment Oct 25, 2018
@luabud
Copy link
Member

luabud commented Sep 11, 2019

Related to #7206

@eElor
Copy link

eElor commented Oct 11, 2019

I observe a similar problem on Windows:

Environment data

  • VS Code version: 1.39.1 (user setup)
  • Extension version: 2019.10.41019
  • OS and version: Windows 10 64-bit
  • Python version: 3.7.4 (conda)
  • Type of virtual environment used: conda (base)
  • Jedi or Language Server?: python.jediEnabled: true

Expected behaviour

  • 'Run File in Python terminal' runs on cmd terminal.
  • 'Run Selection/Line in Python terminal' runs on Python REPL.
  • Each runs independently of previous run and in correct terminal.

Actual behaviour

  • Both commands run on terminal '2: Python'.
  • REPL only initializes once and does not close when 'Run File in Python terminal'.

1) 'Run File in Python terminal'

(OK)
terminal '2: Python' is created and

C:\Users\...>C:/Users/.../Miniconda3/Scripts/activate

(base) C:\Users\...>C:/Users/.../Miniconda3/python.exe "c:/Users/.../Documents/Python Scripts/hello.py"
hello

2) 'Run Selection/Line in Python terminal'

(OK)
REPL in terminal '2: Python' is initialized.

(base) C:\Users\...>C:/Users/.../Miniconda3/python.exe
Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello")
hello

3) Try again 'Run File in Python terminal'

(ERROR => in terminal '2: Python' REPL is still active!!!)

>>> C:/Users/.../Miniconda3/python.exe "c:/Users/.../Documents/Python Scripts/hello.py"
  File "<stdin>", line 1
    C:/Users/.../Miniconda3/python.exe "c:/Users/.../Documents/Python Scripts/hello.py"
      ^
SyntaxError: invalid syntax

selecting terminal '1: cmd' or opening new terminal does not work, since run jumps into '2: Python'.

4) Exit REPL manually

>>> exit()

(base) C:\Users\...>

5) 'Run File in Python terminal'

(OK)

(base) C:\Users\...>C:/Users/.../Miniconda3/python.exe "c:/Users/.../Documents/Python Scripts/hello.py"
hello 

6) 'Run Selection/Line in Python terminal'

(ERROR because of 3) => REPL is not initialized a second time.)

(base) C:\Users\...>print("hello")
Unable to initialize device PRN

Steps to reproduce:

'Run File in Python terminal' tests active terminal. 
        if REPL active:
            run in cmd terminal (which is already open in '1: cmd') 
'Run Selection/Line in Python terminal' tests active terminal.
        if '2: Python' selected and REPL active:
            run 
        else: 
            change to terminal '2: Python' 
            if REPL is not active in '2: Python':
                initialize REPL and run selection

@brettcannon brettcannon added needs decision feature-request Request for new features or functionality and removed needs PR bug Issue identified by VS Code Team member as probable bug labels Dec 3, 2020
@luabud luabud added needs proposal Need to make some design decisions and removed needs decision labels Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-editor-* User-facing catch-all area-repl feature-request Request for new features or functionality needs proposal Need to make some design decisions
Projects
None yet
Development

No branches or pull requests

6 participants