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

Evaluate for a variable with space inside sends an error #1402

Closed
pointhex opened this issue Sep 28, 2023 · 2 comments
Closed

Evaluate for a variable with space inside sends an error #1402

pointhex opened this issue Sep 28, 2023 · 2 comments

Comments

@pointhex
Copy link

Environment data

  • debugpy version: 1.6.7.post1
  • OS and version: Ubuntu 22.04
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.10.6
  • Using VS Code or Visual Studio: -

Actual behaviour

  • sent the "variables" request
  • get the list of the variables with the variable name "function variable" inside
  • sent the request "evaluate"
  • get an error for an existent variable
  • the problem is only there with variables with space inside

log:

variables request:
{"body":{"variables":[{"name":"special variables","type":"","value":"","variablesReference":28},{"name":"function variables","type":"","value":"","variablesReference":29},{"evaluateName":"x.i","name":"i","type":"int","value":"2","variablesReference":0}]},"command":"variables","request_seq":24,"seq":35,"success":true,"type":"response"}

evaluate request:
{\"arguments\":{\"context\":\"variables\",\"expression\":\"function variables\",\"frameId\":2},\"command\":\"evaluate\",\"seq\":25,\"type\":\"request\"}

evaluate response:
{\"seq\": 36, \"type\": \"response\", \"request_seq\": 25, \"success\": true, \"command\": \"evaluate\", \"body\": {\"result\": \"SyntaxError('invalid syntax', ('<string>', 1, 10, 'function variables', 1, 19))\", \"variablesReference\": 30, \"type\": \"SyntaxError\", \"presentationHint\": {}}}

Expected behavior

  • should be possible to evaluate all kinds of variable names which are existed
@int19h
Copy link
Contributor

int19h commented Sep 28, 2023

"evaluate" request, by design, accepts valid Python expressions and evaluates them in the environment of the designated frame; Python does not allow spaces in variables names. Furthermore, the "function variable" item is not an actual variable, just a dummy entry that is used to organize actual variables, so it cannot be referenced in any case except to enumerate child items.

@int19h int19h closed this as completed Sep 28, 2023
@pointhex
Copy link
Author

pointhex commented Sep 29, 2023

@int19h Thank you for the explanation. Is it possible to make this entry name "function_variable" or exchange the space for something else? Currently, it is not possible to make an evaluation for any variables below by the tree(x.function variable.y, etc). Is it possible to do the same with other kinds of entries?

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

No branches or pull requests

2 participants