Python debugger changes __file__
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Reproduce el comportamiento usando la configuración launch.json con script.py y script2.py, comparando F5 con Ctrl-F5 y las rutas de programa relativas con las absolutas. Rastrea cómo el depurador inicia el destino y el subproceso, y verifica después que file coincide con el comportamiento esperado de las rutas absolutas en ambos casos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Type: Bug
Behaviour
Steps to reproduce:
- Make launch.json be like
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "script.py",
"cwd": "<the parent directory of srcipt.py>"
"console": "integratedTerminal",
"justMyCode": true,
}
]
}
and script.py be
print(__file__)
- When I run the script.py with debugger (by F5) the
__file__is "script.py".
When I run the script.py without debugger (by ctrl-F5) the__file__is the absolute path of script.py.
According to https://stackoverflow.com/questions/7116889/is-module-file-attribute-absolute-or-relative, __file__ should be absolute path, because my python version is 3.10.
This happens when "program" of launch.json is relative path.
When "program" is absolute path, the launched script.py's __file__ is absolute path, but if I call subprocess.run(["python", "script2.py"]) in script.py, called script2.py's __file__ becomes "script2.py"
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.12
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
- Value of the
python.languageServersetting: Pylance
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
XXX
User Settings
languageServer: "Pylance"
Extension version: 2023.22.1
VS Code version: Code 1.85.2 (8b3775030ed1a69b13e4f4c628c612102e30a681, 2024-01-18T06:40:10.514Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Remote OS version: Linux x64 5.15.133.1-microsoft-standard-WSL2
Remote OS version: Linux x64 5.15.133.1-microsoft-standard-WSL2
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz (8 x 3600) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | undefined |
| Memory (System) | 31.92GB (21.33GB free) |
| Process Argv | --crash-reporter-id d0837e9f-f8e1-46b8-b5ab-112cca56ee24 |
| Screen Reader | no |
| VM | 0% |
| Item | Value |
|---|---|
| Remote | WSL: Ubuntu |
| OS | Linux x64 5.15.133.1-microsoft-standard-WSL2 |
| CPUs | Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz (8 x 3600) |
| Memory (System) | 19.54GB (17.84GB free) |
| VM | 0% |
| Item | Value |
|---|---|
| Remote | WSL: Ubuntu |
| OS | Linux x64 5.15.133.1-microsoft-standard-WSL2 |
| CPUs | Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz (8 x 3600) |
| Memory (System) | 19.54GB (17.84GB free) |
| VM | 0% |
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes516:30244333
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30933248
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
accentitlementsc:30887149
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
dsvsc019acf:30933242
- Lenguaje dominante
- Python
- Estrellas
- 2.5k
- Forks
- 202
- Merge medio
- 5 d 1 h
- PR fusionados (30 d)
- 1
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/debugpy
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Document "rules"-option Abiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
Adapter bootstrap fails with ConnectionRefusedError on WSL2 VirtioProxy or hostAddressLoopback Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Todos los issues de microsoft/debugpy
Issues similares
-
[Bug] reef-hermes tells me to resume with hermes --resume, which does not work from my shell Abiertoarea: harness bug status: needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Human-Agent-Society/reef#625 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
learningequality/kolibri#15351 · 2 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Name consistency Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
eellak/triplestore#65 · 1 comentario ·