Skip to content

Conversation

guoci
Copy link

@guoci guoci commented Aug 26, 2025

If there is any syntax error in the file where the user sends code, deprecated will be sent to the Python terminal. This PR modifies to show the exception from ast.parse.
Related: #25117

@guoci
Copy link
Author

guoci commented Aug 26, 2025

@microsoft-github-policy-service agree

@anthonykim1
Copy link

anthonykim1 commented Sep 12, 2025

Thanks for the PR, I'm not sure how useful the error would be though.

Usually it means we weren't able to do the "smarts" for smart send in terms of ast parsing the python file properly bc of outdated python version or invalid syntax somewhere in the file.

What were the outputs you would see with this PR?

@guoci
Copy link
Author

guoci commented Sep 12, 2025

import this

if True
    pass

import this

For the above code, when there is invalid syntax, originally, the output will be:
deprecated
But with this PR, the output changes to:
'vscode-python error: SyntaxError("expected \':\'", (\'<unknown>\', 2, 8, \'if True\\n\', 2, 9))'
which gives the location of the syntax error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants