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

Debugger: Dictionaries not correctly listed for multiple key objects with identical representation #148

Closed
mankeph opened this issue Apr 28, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@mankeph
Copy link

mankeph commented Apr 28, 2020

Environment data

  • VS Code version: 1.45.0-insider
  • Extension version (available under the Extensions sidebar): 2020.4.76186
  • OS and version: Linux Mint 18.2
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.8 : Anaconda
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: None
  • Relevant/affected Python-related VS Code extensions and their versions: None
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version vscode-python#3977): [default]
  • Value of the python.languageServer setting: [default]
    (Fresh install of the insider build and default Python extension)

Expected behaviour

Show the full dictionary listing in the debugger "Variables" window.

Actual behaviour

The listing only shows the first occurance of duplicate __repr__ values for dictionary key items.

Steps to reproduce:

class T:
    def __init__(self, name, value):
        self.name = name
        self.value = value
    def __repr__(self):
        return self.name

td = {T("foo", 24): "bar",
      T("gad", 42): "zooks",
      T("foo", 12): "bur"}

print("Keys: " + str((td.keys())))  
print("Values: " + str((td.values()))) # Breakpoint here
  1. We need Python objects that can return identical representations for different objects (__repr__()).
  2. Create multiple of such objects and use them as key values for a dictionary.
  3. Start the debugger and look at the dictionary in the variable listing.
  4. Only the first key from all duplicate representations will be displayed, even though the dictionary may contain multiple different key objects.

Screenshot using the code example:
Dictionary_Debugger_bug

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Apr 28, 2020
@int19h int19h added the bug Something isn't working label May 2, 2020
@int19h
Copy link
Contributor

int19h commented May 2, 2020

It might be a VSCode limitation, or else we're shoving them into a dict somewhere and collapsing the keys in the process. Need to investigate.

@fabioz
Copy link
Collaborator

fabioz commented Jan 22, 2021

I'll investigate this.

@fabioz
Copy link
Collaborator

fabioz commented Jan 22, 2021

This really seems like a limitation VSCode: microsoft/vscode#107506

It seems we need some code to work around that (and I noted that the evaluateName is also wrong in this case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants