You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Attaching using PEP 768 style code injection fails when there's a backslash in the temp path #2037
When attempting to attach using PEP 768 style code injection, the code written to the temp file contains invalid characters if the temp file path contains backslashes (such as "C:\Users\xxx\AppData\Local\Temp\")
This results in an error when the code is attempted to be run:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape (<string>, line 1)
It looks like this was introduced in c7e86a1. The fix would be to escape the path on Windows when writing the file, or simply replace backslashes with forward slashes.
Environment data
debugpy version: 1.8.20
OS and version: Windows 11
Python version: 3.14.5
Using VS Code or Visual Studio: VS Code
Actual behavior
Attempting to attach to a Python 3.14 process on Windows where the temp folder has a "\" in the path fails with the error
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape (<string>, line 1)
Activity
rchiodo commentedon Jun 15, 2026
Yeah this just breaks debugging altogether. I thought it would just force pydevd to be used.
Here's my output after debugging fails:
:\Users\rchiodo\source\testing\docstring_parser>C:\Users\rchiodo\AppData\Local\Programs\Python\Python314\python.exe test_attach.py
PID: 21804
Enter somethingx
Error executing debugger script C:\Users\rchiodo\AppData\Local\Temp\tmp0_vuee4s:
Traceback (most recent call last):
File "C:\Users\rchiodo\source\testing\docstring_parser\test_attach.py", line 5, in
x = input("Enter something")
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape (, line 1)
x
Fix PEP 768 code injection failing with backslash in temp path
Fix PEP 768 code injection SyntaxError when temp path contains backsl…
Fix PEP 768 code injection SyntaxError when temp path contains backsl…