Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Cannot edit collection elements #46

Closed
karthiknadig opened this issue Feb 6, 2018 · 6 comments
Closed

Cannot edit collection elements #46

karthiknadig opened this issue Feb 6, 2018 · 6 comments

Comments

@karthiknadig
Copy link
Member

No description provided.

@int19h
Copy link
Contributor

int19h commented Feb 6, 2018

This appears to be a pydevd bug, where editing a value of, say, the first item in the list executes Python code along the lines of lines.0 = 123 instead of lines[0] = 123.

@karthiknadig
Copy link
Member Author

karthiknadig commented Mar 10, 2018

I tried changing code in pydevd to generate lines[0]. Instead of updating the first item in the lines collection. It actually added a new item to the FRAME named lines[0]. Because, the variables are stored in frame.f_locals[attr] = value.

@int19h
Copy link
Contributor

int19h commented Mar 10, 2018

I think it's because for CMD_CHANGE_VARIABLE, you need to specify the children in the same way as you do for CMD_GET_VARIABLE (i.e. tab-separated like foo\tbar\t1 for foo.bar[1]).

It looks like we'll just have to fix it on pydevd side of things, by accounting for indices in the handling of CMD_CHANGE_VARIABLE.

@int19h
Copy link
Contributor

int19h commented Mar 10, 2018

Actually, to clarify - when you changed that code, did you change it to generate just a single lines[0], or tab-separated lines and [0]?

@karthiknadig
Copy link
Member Author

karthiknadig commented Mar 10, 2018

The command args looked like this: <tid>\t<fid>\tFRAME\tlines[0]\t1234. The issue is actually in pydevd_vars.py. Get variable code uses type resolver to get to the actual value. Where as set variable does not use type resolver, instead it directly attempts to change the value.

@int19h int19h added this to the VS stable milestone Mar 12, 2018
@karthiknadig
Copy link
Member Author

This is the result of setVariable with following inputs:
['pid_26312_id_1588235631248', '1588252057672', 'EXPRESSION', 'lines[0]', '22']

Result:
image

Instead of updating, it created a new variable.

And for this case:
['pid_3364_id_2123742022344', '2123757001656', 'EXPRESSION', 'lines', '[0]', '22']

you will get this error:

Traceback (most recent call last):
  File "G:\git\ptvsd\ptvsd\pydevd\_pydevd_bundle\pydevd_vars.py", line 396, in change_attr_expression
    Exec('%s=%s' % (attr, expression), frame.f_globals, frame.f_locals)
  File "G:\git\ptvsd\ptvsd\pydevd\_pydevd_bundle\pydevd_exec2.py", line 3, in Exec
    exec(exp, global_vars, local_vars)
  File "<string>", line 1
    lines.[0]=22
          ^

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

No branches or pull requests

2 participants