Replies: 2 comments
-
Sorry I transferred this to discussions as it's not really an issue. I believe there are settings you can use to specify which files are just my code or not. Looking them up now. |
Beta Was this translation helpful? Give feedback.
0 replies
-
You should be able to mark files as system code by using the rules option in the launch.json (well assuming they're all generated in a specific directory). See the discussion here: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
Debugpy uses the frame's
co_filename
in many ways. It uses it for debuginfo caching, to determine whether it's user code or not (which affects behavior of the settingjustMyCode
), and whether to interpret the source code as raw Python code or Python bytecode.For example, the filename is handled differently if it begins with
<
. It is considered non-user code not sourced from a file:debugpy/src/debugpy/_vendored/pydevd/pydevd_file_utils.py
Line 481 in 1aff9aa
debugpy/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py
Line 62 in 1aff9aa
debugpy/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_api.py
Line 535 in 1aff9aa
Some more special names include:
debugpy/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py
Lines 47 to 59 in 1aff9aa
It is also important whether the file ends with ".py", as in this case inspecting this file in VSCode enables syntax highlighting.
This works well for the regular Python files. But there is an edge case of runtime-compiled modules for which you can assign the filename dynamically. For example: https://github.com/wbond/pymeta3/blob/master/pymeta/builder.py#L309-L326
Question
How do I pick the name for a runtime-compiled module (not backed up by an actual source file) so that it plays well with debugpy?
/
, debugpy interprets this runtime-compiled module as user code, even if everything happens in a library. This may lead to cryptic errors.<generated myfile.py>
, VSCode renders it as Python bytecode even when Python code is available for the frame.<
or/
, it's normalized to a non-existent file path under.../site-packages/{filename}
.What works well is a filename such as
<generated>myfile.py
. It begins with<
and ends with.py
, which ensures a correct interpretation. I wonder if such a naming makes sense from the point of view of debugpy, and whether there's a better way to achieve my goal that I'm missing.Beta Was this translation helpful? Give feedback.
All reactions