Skip to content

Conversation

@rchiodo
Copy link
Contributor

@rchiodo rchiodo commented Mar 10, 2025

In this issue:
#1857

The user is trying to assign the global 'c' to a new value while inside of a function. Since the variable is listed under 'globals', you'd think this would just work.

Internally we don't actually assign it to globals unless the user types globals()['c']=value, but that doesn't really make sense from the variables panel.

I found that the scope of the variable is passed in the setVariables request, so we can use that to determine if the variable was originally a global or not and assign it to the correct scope.

I tested this with Pydevd's test automation and by using VS code.

Addresses #1857

@rchiodo rchiodo requested a review from a team as a code owner March 10, 2025 17:59
return

child_var = variable.change_variable(arguments.name, arguments.value, py_db, fmt=fmt)
child_var = variable.change_variable(arguments.name, arguments.value, py_db, fmt=fmt, scope=scope)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the setVariable request is handled. I added the scope to the change_variable

@rchiodo rchiodo merged commit f7d8963 into microsoft:main Mar 10, 2025
22 of 24 checks passed
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