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

"<class ...>" not shown when an error is raised #14098

Closed
salemileandro opened this issue Aug 10, 2023 · 1 comment
Closed

"<class ...>" not shown when an error is raised #14098

salemileandro opened this issue Aug 10, 2023 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@salemileandro
Copy link

Environment data

  • VS Code version: 1.81.1, 6c3e3dba23e8fadc360aed75ce363ba185c49794, arm64
  • Jupyter Extension version (available under the Extensions sidebar): v2023.7.1002162226
  • Python Extension version (available under the Extensions sidebar): v2023.14.0
  • OS (Windows | Mac | Linux distro) and version: macOS Ventura 13.3.1
  • Python and/or Anaconda version: Python 3.10.12, conda 23.7.2
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Jupyter server running: Local

Expected behaviour

Running the following cell

x = int(10)
if not isinstance(x, float):
    message = (
        f"x is not of type {float} but {type(x)=}.\n"
        "(1) <class int> (2) < class int> (3) <class int > (4) < class int >"
    )
    print(message)
    raise TypeError(message)

I expect to get this as an output

x is not of type <class 'float'> but type(x)=<class 'int'>.
(1) <class int> (2) < class int> (3) <class int > (4) < class int >
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[7], line 9
      4 message = (
      5     f"x is not of type {float} but {type(x)=}.\n"
      6     "(1)  (2) < class int> (3)  (4) < class int >"
      7 )
      8 print(message)
----> 9 raise TypeError(message)

TypeError: x is not of type  but type(x)=.
(1) <class int> (2) < class int> (3) <class int > (4) < class int >

Actual behaviour

The output is actually

x is not of type <class 'float'> but type(x)=<class 'int'>.
(1) <class int> (2) < class int> (3) <class int > (4) < class int >
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[7], line 9
      4 message = (
      5     f"x is not of type {float} but {type(x)=}.\n"
      6     "(1)  (2) < class int> (3)  (4) < class int >"
      7 )
      8 print(message)
----> 9 raise TypeError(message)

TypeError: x is not of type  but type(x)=.
(1)  (2) < class int> (3)  (4) < class int >

The print statement shows the message properly, but raise part doesn't (the last line is not complete).
From what I understand, when an error is raised, if the text contains something like <class int>, then this particular bit of the message is not shown. I think <class ...> doesn't get an interpreter as a string but as an HTML tag.

Steps to reproduce:

  1. Open a notebook (python kernel)
  2. Execute the cell
x = int(10)
if not isinstance(x, float):
    message = (
        f"x is not of type {float} but {type(x)=}.\n"
        "(1) <class int> (2) < class int> (3) <class int > (4) < class int >"
    )
    print(message)
    raise TypeError(message)

Logs

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

Visual Studio Code (1.81.1, undefined, desktop)
Jupyter Extension Version: 2023.7.1002162226.
Python Extension Version: 2023.14.0.
Platform: darwin (arm64).
Workspace folder ~/Documents/housing, Home = /Users/leandro
23:37:00.906 [info] User belongs to experiment group 'FastKernelPicker'
23:37:00.906 [info] User belongs to experiment group 'NewRemoteUriStorage'
23:37:00.906 [info] User belongs to experiment group 'PasswordManager'
23:37:00.906 [info] User belongs to experiment group 'NewJupyterSession'
23:37:01.157 [info] Start refreshing Kernel Picker (1691703421157)
23:37:01.158 [info] Using Pylance
23:37:01.174 [info] Start refreshing Interpreter Kernel Picker
23:37:02.011 [info] Starting Kernel startUsingPythonInterpreter, .jvsc74a57bd00aa12bc89be0f13c5ae698ac78d8136ea8c98d79e372b4a4da246eb831105402.~/miniconda3/envs/scraping/python.~/miniconda3/envs/scraping/python.-m#ipykernel_launcher  (Python Path: ~/miniconda3/envs/scraping/bin/python, Conda, scraping, 3.9.16) for '~/Documents/.private/housing/dev.ipynb' (disableUI=true)
23:37:02.632 [info] Process Execution: ~/miniconda3/envs/icr/bin/python -m pip list
23:37:03.002 [info] Process Execution: ~/miniconda3/envs/scraping/bin/python -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
23:37:03.003 [info] Process Execution: ~/miniconda3/envs/scraping/bin/python -m ipykernel_launcher --ip=127.0.0.1 --stdin=9003 --control=9001 --hb=9000 --Session.signature_scheme="hmac-sha256" --Session.key=b"07137207-a2ae-4770-8288-08e3f2a8187b" --shell=9002 --transport="tcp" --iopub=9004 --f=~/Library/Jupyter/runtime/kernel-v2-12145JFncbO2Orc4H.json
    > cwd: ~/Documents/.private/housing
23:37:03.006 [info] Process Execution: ~/miniconda3/envs/scraping/bin/python -m pip list
23:37:03.117 [info] ipykernel version & path 6.22.0, ~/miniconda3/envs/scraping/lib/python3.9/site-packages/ipykernel/__init__.py for ~/miniconda3/envs/scraping/bin/python
23:37:03.324 [warn] StdErr from Kernel Process ~/miniconda3/envs/scraping/lib/python3.9/site-packages/traitlets/traitlets.py:2548: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
  warn(
23:37:03.324 [warn] StdErr from Kernel Process ~/miniconda3/envs/scraping/lib/python3.9/site-packages/traitlets/traitlets.py:2499: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '07137207-a2ae-4770-8288-08e3f2a8187b' instead of 'b"07137207-a2ae-4770-8288-08e3f2a8187b"'.
  warn(
23:37:03.421 [info] Started Kernel scraping (Python 3.9.16) (pid: 12255)
23:37:03.421 [info] Started new session ea3d6074-8637-41e7-a822-e88fde8d0399
23:37:03.465 [info] Process Execution: ~/miniconda3/envs/scraping/bin/python ~/.vscode/extensions/ms-toolsai.jupyter-2023.7.1002162226-darwin-arm64/pythonFiles/printJupyterDataDir.py
23:37:03.490 [warn] Got a non-existent Jupyer Data Dir file://~/.local/share/jupyter
23:37:03.626 [info] End refreshing Kernel Picker (1691703421157)
23:37:04.916 [info] Handle Execution of Cells 1 for ~/Documents/.private/housing/dev.ipynb
23:37:04.925 [info] Kernel acknowledged execution of cell 1 @ 1691703424921
23:37:05.095 [info] End cell 1 execution @ 1691703425093, started @ 1691703424921, elapsed time = 0.172s
23:37:05.095 [warn] Cancel all remaining cells due to cancellation or failure in execution

@salemileandro salemileandro added the bug Issue identified by VS Code Team member as probable bug label Aug 10, 2023
@amunger
Copy link
Contributor

amunger commented Aug 10, 2023

duplicate of microsoft/vscode#177405

@amunger amunger closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2023
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