Skip to content

Avoid exceptions in environment diagnostics - #2059

Merged
Rich Chiodo (rchiodo) merged 2 commits into
mainfrom
rchiodo-fix-real-prefix-exception
Aug 7, 2026
Merged

Avoid exceptions in environment diagnostics#2059
Rich Chiodo (rchiodo) merged 2 commits into
mainfrom
rchiodo-fix-real-prefix-exception

Conversation

@rchiodo

Copy link
Copy Markdown
Contributor

Summary

  • avoid raising AttributeError while probing sys.real_prefix
  • use the Python 3.10+ standard-library importlib.metadata API instead of probing for the backport
  • verify environment diagnostics do not emit debugpy-internal exceptions

Fixes #2058

Tests

  • python -m pytest -q -o addopts='' tests\debugpy\test_log.py::test_environment_description_does_not_raise_internal_exceptions 'tests\debugpy\test_exception.py::test_vsc_exception_options_raise_with_except[program-launch--raised]'
  • python -m black --check src\debugpy\common\log.py tests\debugpy\test_log.py
  • python -m ruff check src\debugpy\common\log.py tests\debugpy\test_log.py

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@rchiodo
Rich Chiodo (rchiodo) requested a review from a team as a code owner August 7, 2026 17:00
@StellaHuang95

Copy link
Copy Markdown
Contributor

🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR.

Comment thread tests/debugpy/test_log.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@StellaHuang95 Stella Huang (StellaHuang95) added the review-auto:approved Automated review: no blocking findings (approval posted). label Aug 7, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@rchiodo
Rich Chiodo (rchiodo) merged commit 7d3f861 into main Aug 7, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debugger breaks on internal AttributeError: module 'sys' has no attribute 'real_prefix' with "Raised Exceptions" enabled

2 participants