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
{{ message }}
Repository navigation
Smart send often doesn't work when file contain Python2 code #22318
Daniel Imms (@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.
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.
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.
Activity
Tyriar commentedon Oct 24, 2023
This happens with and without:
anthonykim1 commentedon Oct 24, 2023
Daniel Imms (@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.
anthonykim1 commentedon Oct 25, 2023
Daniel Imms (@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:
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.
[-]Smart send often doesn't work[/-][+]Smart send often doesn't work when file contain Python2 code[/+]Tyriar commentedon 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.
anthonykim1 commentedon Dec 7, 2023
Closed as resolved with #22340 and #22341