Debugger console prints the key when the key doesn't exist in a dict
See original GitHub issueEnvironment data
VS Code version: 1.19.3 Python Extension version: 0.9.1 Python Version: 2.7.12 OS and version: Ubuntu 16.04.3 x64
Actual behavior
The debugger console gives a weird result when indexing a dict with a key that doesn’t exist in the dict. It prints the key… which is confusing and unexpected.
Expected behavior
It prints that the key doesn’t exist. (KeyError
)
Steps to reproduce:
- Debug a file that has a dict, for example:
a = {'a': 123}
- Type in the debugger console:
>>> a['a']
123
>>> a['b']
'b' # ???
GIF
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
The given key was not present in the dictionary. Which key?
Problem here is that the debugger is not always available, for example when reading log file. – Andreas. Oct 7, 2014 at 20:10....
Read more >Debug mode doesn't print entire dictionary in python - GitHub
Issue Type: Bug. Running a Python script in debug mode will not print the entire dictionary. Just prints partial data.
Read more >Check whether given Key already exists in a Python Dictionary
This article will be focusing on the Python program to check whether a given key already exists in a dictionary.
Read more >pdb — The Python Debugger — Python 3.11.1 documentation
Enter the debugger at the calling stack frame. This is useful to hard-code a breakpoint at a given point in a program, even...
Read more >Errors, Logging, and Debugging - Hydro-Informatics
A mapping key is not found. May occur when referencing a non-existing dictionary key. ImportError. Importing a module that does not exist.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, @elliott-beach for verifying!
This feature is currently not supported, some work was done to add support for this PythonProcessCallbackHandler.ts#L273, but was never comlpeted.
I believe this can be done.
As a first step, I’d saw we need to ensure the error message (
b
) is being handled and displayed. Then we can look at supporting rich exceptions.Oh yes, thanks for identifying the issue in the code.