Skip to content

When using the debugger, OrderedDict should display its content according to the insertion order #3471

@PetitPrince

Description

@PetitPrince

Environment data

  • VS Code version: 1.29.1
  • Extension version (available under the Extensions sidebar): 2018.10.1
  • OS and version: Windows 10 1803
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A

Actual behavior

When debugging a Python script, OrderedDicts displays their content in a seemingly random order.

ordered_dict_debug

Expected behavior

OrderedDicts should display their content according to the insertion order.

Steps to reproduce:

  1. Save the following code in a file
from collections import OrderedDict

if __name__ == "__main__":
    my_ordered_dict = OrderedDict()
    my_ordered_dict['trois'] = 3
    my_ordered_dict['deux'] = 2
    my_ordered_dict['un'] = 1
    my_ordered_dict['zero'] = 0
    print(my_ordered_dict)
    
  1. Set a breakpoint on the print function (last line)
  2. Look at either the Debug panel or the Object representation on the Debug Console. Curiously, directly calling the str or repr shows the expected behavior.

Note

This is very similar to #3236 , but it uses OrderedDict instead of the regular dict and it also happens on the debug panel ( #3236 only mentions the console, I don't know how close those two elements are linked). I hope this issue is not too redundant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions