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 in Python Terminal - SyntaxError #6334

Closed
DougPlumley opened this issue Jun 25, 2019 · 4 comments
Closed

Run Selection/Line in Python Terminal - SyntaxError #6334

DougPlumley opened this issue Jun 25, 2019 · 4 comments
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug partner ask

Comments

@DougPlumley
Copy link

Environment data

  • VS Code version: 1.35.1
  • Extension version (available under the Extensions sidebar): 2019.6.22090
  • OS and version: macOS Mojave 10.14.4
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): Microsoft Python Language Server version 0.3.20.0

Expected behaviour

The following code should run as expected when executed using "Run Selection/Line in Python Terminal".

{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}
{
    "test": "test",
    "test2": "test2"
}

Actual behaviour

Approximately 1/5 of the time on my machine it will result in a syntax error. I've noticed this becomes more of an issue the longer my selection is. For example I can't reproduce the error using the above code when I only have lines 1 - 88 selected (989 total characters). When I select 1 - 92 (1035 total characters) the issue starts occurring. Note that characters in the Python terminal start to be transposed which may suggest there's some sort of race condition as data from the source is inserted into the terminal.

>>> 
>>> {
...     "test": "test",
...     "test2": "test2"
... }
{'test': 'test', 'test2': 'test2'}
>>> 
>>> {
...     "test":     "test":     "t": "test2"
  File "<stdin>", line 2
    "test":     "test":     "t": "test2"
                      ^
SyntaxError: invalid syntax
>>> }
  File "<stdin>", line 1
    }
    ^
SyntaxError: invalid syntax

Steps to reproduce:

  1. Copy example code into source file
  2. Select lines 1 - 92
  3. Run selection repeatedly until error occurrs

run-selection-error

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Microsoft Python language server.
[Info  - 4:55:56 PM] Analysis cache path: /Users/dplumley/Library/Caches/Microsoft/Python Language Server
[Info  - 4:55:56 PM] GetCurrentSearchPaths /usr/local/bin/python3 
[Info  - 4:55:57 PM] Interpreter search paths:
[Info  - 4:55:57 PM]     /private/var/folders/h1/gp3rgbx518zcprwky90s5y_80000gp/T/egh4vhvx.wqq
[Info  - 4:55:57 PM]     /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7
[Info  - 4:55:57 PM]     /usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload
[Info  - 4:55:57 PM]     /usr/local/lib/python3.7/site-packages
[Info  - 4:55:57 PM] User search paths:
[Info  - 4:55:57 PM] Microsoft Python Language Server version 0.3.20.0
[Info  - 4:55:57 PM] Initializing for /usr/local/bin/python3

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

[Extension Host] Info Python Extension: 2019-06-25 16:58:20: Cached data exists getEnvironmentVariables, <No Resource>
workbench.main.js:238 [Extension Host] Info Python Extension: 2019-06-25 16:58:22: Cached data exists getEnvironmentVariables, <No Resource>
@DougPlumley DougPlumley added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Jun 25, 2019
@DougPlumley
Copy link
Author

I'll also mention that this seems to start occurring after I select 1024+ characters which is an interesting number to start to see an issue at.

Example:

{
    "test": "test",
    "test2": "test",
    "test3": "test",
    "test4": "test",
    "test5": "test",
    "test6": "test",
    "test7": "test",
    "test8": "test",
    "test9": "test"
}
{
    "test": "test",
    "test2": "test",
    "test3": "test",
    "test4": "test",
    "test5": "test",
    "test6": "test",
    "test7": "test",
    "test8": "test",
    "test9": "test"
}
{
    "test": "test",
    "test2": "test",
    "test3": "test",
    "test4": "test",
    "test5": "test",
    "test6": "test",
    "test7": "test",
    "test8": "test",
    "test9": "test"
}
{
    "test": "test",
    "test2": "test",
    "test3": "test",
    "test4": "test",
    "test5": "test",
    "test6": "test",
    "test7": "test",
    "test8": "test",
    "test9": "test"
}
{
    "test": "test",
    "test2": "test",
    "test3": "test",
    "test4": "test",
    "test5": "test",
    "test6": "test",
    "test7": "test",
    "test8": "test",
    "test9": "test",
    "test9": "test",
    "test9": "test",
    "test9": "test1234",
}

@brettcannon brettcannon added triage and removed triage-needed Needs assignment to the proper sub-team labels Jun 26, 2019
@ericsnowcurrently
Copy link
Member

This is a known upstream issue: microsoft/vscode#38137. It is possible that we could temporarily work around the problem in the Python extension (e.g. chunk the data sent to the terminal), but I'm not sure. We'll look into it.

@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Jun 27, 2019
@ghost ghost removed triage-needed Needs assignment to the proper sub-team labels Jun 27, 2019
@DougPlumley
Copy link
Author

Thanks @ericsnowcurrently !

@ericsnowcurrently ericsnowcurrently removed their assignment Aug 12, 2019
@luabud
Copy link
Member

luabud commented Sep 17, 2019

Closing in favour of microsoft/vscode#38137.

@luabud luabud closed this as completed Sep 17, 2019
@ghost ghost removed needs decision labels Sep 17, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug partner ask
Projects
None yet
Development

No branches or pull requests

4 participants