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

View value in Data Viewer exception when viewing class variables #4606

Closed
q-wertz opened this issue Feb 2, 2021 · 8 comments
Closed

View value in Data Viewer exception when viewing class variables #4606

q-wertz opened this issue Feb 2, 2021 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@q-wertz
Copy link

q-wertz commented Feb 2, 2021

Environment data

  • VS Code version: 1.52.1
  • Extension version (available under the Extensions sidebar): ms-python.python 2021.1.502429796
  • OS and version: Ubuntu 20.10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions:
    • jupyter-lab 2.2.5
  • Relevant/affected Python-related VS Code extensions and their versions:
    • ms-toolsai.jupyter v2020.12.414227025
  • Value of the python.languageServer setting: Pylance

Expected behaviour

When creating a class it should be possible to view the instance variables in the the Data Viewer.

Actual behaviour

Instance variables cannot be viewed in the data viewer and errors are raised. In the case in the mp4 below:

Error: Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'a' is not defined

In a bigger class I get some different error, just cannot reproduce it in a short example:

Error: Traceback (most recent call last):
  File "/home/user1/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 416, in evaluate_expression
    compiled = compile(_expression_to_evaluate(expression), '<string>', 'eval')
  File "<string>", line 1
    _VSCODE_DataFrameImport._VSCODE_getDataFrameInfo([0:969] )
                                                       ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user1/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 969, in internal_evaluate_expression_json
    pydevd_vars.evaluate_expression(py_db, frame, expression, is_exec=True)
  File "/home/user1/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 368, in new_func
    return _run_with_unblock_threads(original_func, py_db, curr_thread, frame, expression, is_exec)
  File "/home/user1/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 336, in _run_with_unblock_threads
    return _run_with_interrupt_thread(original_func, py_db, curr_thread, frame, expression, is_exec)
  File "/home/user1/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 307, in _run_with_interrupt_thread
    return original_func(py_db, frame, expression, is_exec)
  File "/home/user1/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 418, in evaluate_expression
    Exec(_expression_to_evaluate(expression), updated_globals, frame.f_locals)
  File "/home/user1/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_exec2.py", line 3, in Exec
    exec(exp, global_vars, local_vars)
  File "<string>", line 1
    _VSCODE_DataFrameImport._VSCODE_getDataFrameInfo([0:969] )
                                                       ^
SyntaxError: invalid syntax

Steps to reproduce:

bugreport2.mp4

As you can see, in the second part of the video after adding variable a when I try to open the tc.a class instance the a variable is shown.

To me it looks like the wrong variable name is handed over to the Data Viewer.

Sample Code:

import numpy as np

class Bugrep:
    def __init__(self, i: int) -> None:
        self.a = np.random.rand(i,i)
        self.b = 3
        self.c = [3, 5, 6, 7, 8]


tc = Bugrep(3)

a1 = np.random.rand(10, 10)
a = np.random.rand(3,3)

print(tc.a)

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Error 2021-02-02 17:04:57: Failed to create File hash for interpreter python [Error: ENOENT: no such file or directory, lstat 'python'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: 'python'
}
Error 2021-02-02 17:04:57: Failed to create File hash for interpreter python [Error: ENOENT: no such file or directory, lstat 'python'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: 'python'
}
Error 2021-02-02 17:04:58: Failed to create File hash for interpreter python [Error: ENOENT: no such file or directory, lstat 'python'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: 'python'
}
> python ~/.vscode/extensions/ms-python.python-2021.1.502429796/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"

@joyceerhl joyceerhl transferred this issue from microsoft/vscode-python Feb 2, 2021
@joyceerhl
Copy link
Contributor

Great catch, this is happening because we are using the name property on the DebugProtocol.Variable that we get from the context menu to get the variable value rather than the fully-qualified evaluateName property.

https://github.com/microsoft/vscode-debugadapter-node/blob/5e4b7803a48d9249c535fb47ad70225e1077431c/debugProtocol.json#L3321-L3323

@joyceerhl joyceerhl added the bug Issue identified by VS Code Team member as probable bug label Feb 3, 2021
@q-wertz
Copy link
Author

q-wertz commented Feb 3, 2021

Thanks for the fast response and solution :)

@joyceerhl
Copy link
Contributor

No problem! Fix should become available in our February release (in a couple weeks' time). Thanks for taking the time to report a bug 😊

@rchiodo
Copy link
Contributor

rchiodo commented Feb 9, 2021

Validated. tc.a is viewable now in the data viewer.

@rchiodo rchiodo closed this as completed Feb 9, 2021
@q-wertz
Copy link
Author

q-wertz commented Mar 1, 2021

Not sure if this patch has been already applied but in ms-toolsai.jupyter v2021.2.603412351 the problem is still persistent...

@joyceerhl
Copy link
Contributor

@q-wertz the fix for this went out in v2021.2.603412351. I'm not able to reproduce the class variables issue, i.e. if I run the code you provided above and right click on tc.a and tc.c, I can open both of those without any issues. Are you saying that you still cannot view class variables?

@q-wertz
Copy link
Author

q-wertz commented Mar 2, 2021

Sorry restarted the IDE and now it works 🎉

@joyceerhl
Copy link
Contributor

Awesome, thanks for confirming and again thanks for reporting a bug!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants