Skip to content

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

Closed

Description

@Tyriar

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)
커밋: 7dff078
날짜: 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

Activity

  1. Tyriar commented on Oct 24, 2023

    @Tyriar
    Author

    This happens with and without:

    "python.experiments.enabled": true, 
    "python.experiments.optInFrom": ["pythonREPLSmartSend"], 
    
  2. anthonykim1 commented on Oct 24, 2023

    @anthonykim1

    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.

  3. anthonykim1 commented on Oct 25, 2023

    @anthonykim1

    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:

    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.

  4. changed the title [-]Smart send often doesn't work[/-] [+]Smart send often doesn't work when file contain Python2 code[/+] on Oct 25, 2023
  5. Tyriar commented on Oct 25, 2023

    @Tyriar
    Author

    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.

  6. anthonykim1 commented on Dec 7, 2023

    @anthonykim1

    Closed as resolved with #22340 and #22341

  7. locked as resolved and limited conversation to collaborators on Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions