Closed
Description
Before creating a new issue, please check the FAQ to see if your question is answered there.
Environment data
- debugpy version: the one bundled with VS Code extension
ms-python.debugpy-2025.0.0-win32-x64
- OS and version: Windows 10
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.11
- Using VS Code or Visual Studio: VS Code
Actual behavior
debugpy
throws an error
Expected behavior
It should not raise an error in debugpy
or cause VS Code debugging to freeze.
Steps to reproduce:
- Create a file with the following content:
class KillDebugpy():
def __getattribute__(self, _):
return self
a = KillDebugpy()
print('Done')
- Add a breakpoint in front of
print()
- Start debugging the file in VS Code.
- Observe the following error in terminal, and it freezes VS Code debugging interface (you cannot stop it in UI.)
> cmd /C "c:\Users\{masked}\AppData\Local\Programs\Python\Python311\python.exe c:\Users\{masked}\.vscode\extensions\ms-python.debugpy-2025.0.0-win32-x64\bundled\libs\debugpy\launcher 11138 -- D:\sync\code\python\trysail\_test4.py "
0.77s - Error processing internal command.
Traceback (most recent call last):
File "c:\Users\{masked}\.vscode\extensions\ms-python.debugpy-2025.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydevd.py", line 2245, in _do_wait_suspend
internal_cmd.do_it(self)
File "c:\Users\{masked}\.vscode\extensions\ms-python.debugpy-2025.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 565, in do_it
self.method(dbg, *self.args, **self.kwargs)
File "c:\Users\{masked}\.vscode\extensions\ms-python.debugpy-2025.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_constants.py", line 531, in new_func
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\{masked}\.vscode\extensions\ms-python.debugpy-2025.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 813, in internal_get_variable_json
py_db.writer.add_command(NetCommand(CMD_RETURN, 0, variables_response, is_json=True))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\{masked}\.vscode\extensions\ms-python.debugpy-2025.0.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_net_command.py", line 80, in __init__
text = json.dumps(as_dict)
^^^^^^^^^^^^^^^^^^^
File "c:\Users\{masked}\AppData\Local\Programs\Python\Python311\Lib\json\__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\{masked}\AppData\Local\Programs\Python\Python311\Lib\json\encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\{masked}\AppData\Local\Programs\Python\Python311\Lib\json\encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "c:\Users\{masked}\AppData\Local\Programs\Python\Python311\Lib\json\encoder.py", line 180, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type <__main__.KillDebugpy object at 0x00000179EC1F9E50> is not JSON serializable
This bug was first observed in real-world code (see: mikf/gallery-dl#6582 (comment)), and I then created a minimal reproducible example based on it.