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

Smart send often doesn't work when file contain Python2 code #22318

Closed
Tyriar opened this issue Oct 24, 2023 · 5 comments
Closed

Smart send often doesn't work when file contain Python2 code #22318

Tyriar opened this issue Oct 24, 2023 · 5 comments
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@Tyriar
Copy link
Member

Tyriar commented Oct 24, 2023

Testing #22287

Most of the time I try to run the shift+enter command without a selection it results in this runtime error:

Image

버전: 1.84.0-insider (user setup)
커밋: 7dff07893ac160244db210e574eccc05f1cba2cb
날짜: 2023-10-24T05:33:54.929Z
Electron: 25.9.2
ElectronBuildId: 24603566
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.22621

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Oct 24, 2023
@Tyriar
Copy link
Member Author

Tyriar commented Oct 24, 2023

This happens with and without:

"python.experiments.enabled": true, 
"python.experiments.optInFrom": ["pythonREPLSmartSend"], 

@anthonykim1
Copy link

anthonykim1 commented Oct 24, 2023

@Tyriar What python version are you using?
Does it also crash your VS Code?
Would you mind sending me what code you are shift+entering on? Having hard time reproducing it.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Oct 24, 2023
@anthonykim1
Copy link

anthonykim1 commented Oct 25, 2023

@Tyriar The reason why this didn't work(for the file provided in slack specifically) is because the test file (one mentioned in Slack) that were being used to test smart send feature: https://github.com/microsoft/vscode/blob/3d7ff4a237b5eccf6bedc9902d75a0e228cc742d/extensions/vscode-colorize-tests/test/colorize-fixtures/test.py#L51, contained code block:

def beliebig(x, y, *mehr):
    print "x=", x, ", x=", y
    print "mehr: ", mehr

which is only valid in Python2.

Minimum official support we have is Python3.8 and above, and end_lineno attribute from the AST module is only supported on Python3.8 and above. So it make sense why shift+enter did not "do" anything when the file contained the mentioned code segment.

Smart Send would error out on Python2 code above. I think Python2 is no longer supported as of January 1st, 2020, hence make sense AST doesn't pickup Python2 code properly and manages to messed up parsing of the other contents of the given Python file as well.

When you shift+enter on the any part of the Python file (some other Python3 code block that were in the file), the smart send logic and Python standard library module AST has to parse through the file in order to collect, and hence allow me to perform smart selection logic, and in that process it errors out. It also make sense that normal explicit highlighting selection will work because we don't have to parse through Python file like we have to for Smart Send (and hence smart selection) logic.

Commenting out the Python2 code should allow you to use Smart Send without this issue!
Thanks for testing, once again.

Edit: Incoming message/warning/notification + user setting in regards to smart send on file with outdated Python code and toggling smart send on/off.

@anthonykim1 anthonykim1 changed the title Smart send often doesn't work Smart send often doesn't work when file contain Python2 code Oct 25, 2023
@anthonykim1 anthonykim1 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
@Tyriar
Copy link
Member Author

Tyriar commented Oct 25, 2023

Ideally we would fallback to something like sending just the line. Alternatively we could show some error notification, but I think just sending the line would be better.

@Tyriar Tyriar reopened this Oct 25, 2023
@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Oct 25, 2023
@anthonykim1
Copy link

Closed as resolved with #22340 and #22341

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

2 participants