Skip to content

Add python 3.15 to tests - #2069

Merged
Finn Womack (finnagin) merged 9 commits into
microsoft:mainfrom
finnagin:py315
Sep 1, 2026
Merged

Finn Womack (finnagin) merged 9 commits into
microsoft:mainfrom
finnagin:py315

Conversation

@finnagin

Copy link
Copy Markdown
Collaborator

No description provided.

Verify that an exception already reported as unhandled remains
recognized after a nested exception replaces the transient exception
state. This prevents the original exception from being reported twice.
Track the identity of an exception once it has been reported as
unhandled so that nested exceptions cannot cause it to be reported
again. Clear the transient exception state before stopping while
retaining the reported exception tag for the remainder of its unwind.

This fixes duplicate SystemExit stops exposed by Python 3.15, where
traceback formatting can trigger a nested monitored exception while
resolving its lazy _colorize import.
Regenerate the .pyx and .c files from the modified
_pydevd_sys_monitoring.py implementation.
Python 3.15 propagates the multithreaded os.fork() DeprecationWarning
as an exception when warnings are configured as errors. Debuggee test
sessions set PYTHONWARNINGS=error, and debugpy's worker threads cause
CPython to emit this warning during the multiprocessing fork tests.

The child process has already been created when the warning is raised
in the parent. This terminates the parent while the child is attaching,
resulting in premature terminated events or test timeouts.

Ignore only this specific warning when the test intentionally uses the
fork start method. Other warnings remain errors, and spawn-based tests
are unaffected.
@finnagin

Copy link
Copy Markdown
Collaborator Author

The tests are all passing now. There were 2 issues uncovered by updating to 3.15.

The smaller issue was that there was a deprecation warning for calling os.fork from a process with multiple threads. That warning was added in 3.12 but was not originally raised to be an error by cpython when PYTHONWARNINGS=error was set. This was a bug and was fixed in 3.15 (python/cpython#135427) and now, because it's raising an error, caused a few multiprocessing tests to fail.

This was fixed by adding a step in those tests to ignore that specific deprecation warning since those tests were specifically testing os.fork.

The larger issue involved duplicate exception stops when using the sys.monitoring backend in the vendored pydevd code. Pydevd keeps a temporary thread-local state identifying the exception currently being tracked as unhandled. That state was used both to locate the exception’s unhandled boundary and to determine whether the exception had already caused a debugger stop.

While pydevd was processing the first unhandled SystemExit stop, it formatted the exception’s traceback. Python 3.15 traceback code now has a lazy import for _colorize. This lazy import triggers during the handling of the SystemExit stop. During that import, the import machinery probes collections.abc.__path__, which raises a benign, caught AttributeError. Pydevd’s monitoring callbacks observed that nested exception and replaced the temporary state that had identified the original SystemExit with a new temporary state for the AttributeError.

When execution continued, the original SystemExit resumed unwinding. Because its identifying state had been replaced by the nested AttributeError, pydevd no longer recognized it as already reported and stopped on the same SystemExit a second time. Since the import in 3.14 was eager, the caught AttributeError happened earlier in the code, so the bug wasn't triggered.

This second issue was fixed by tracking an already-reported exception separately from the temporary state used to find its unhandled boundary. Nested exceptions then can replace the temporary state, but won't erase the record that the original exception has already caused a debugger stop. Also, a test was added to check this specific bug instead of relying on it incidentally getting triggered by an unrelated change in the timing of when a module gets imported.

@finnagin
Finn Womack (finnagin) marked this pull request as ready for review August 31, 2026 16:04
@finnagin
Finn Womack (finnagin) requested a review from a team as a code owner August 31, 2026 16:04
@bschnurr

Bill Schnurr (bschnurr) commented Aug 31, 2026

Copy link
Copy Markdown
Member

🔒 Automated review in progress — Bill Schnurr (@bschnurr) is auto-reviewing this PR.

@bschnurr

Copy link
Copy Markdown
Member

Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified.

Result: could-not-verify

Summary: Verification could not run because no trusted sandbox image is configured for `microsoft/debugpy`. The PR adds one regression test for repeated unhandled-exception reporting in the pure-Python monitoring implementation. No executable pass/fail signal was obtained. Coverage is still missing for the parallel Cython implementation and Python 3.15 attach-version detection.

Test runs: 1 not run

  • ⚠️ Not run | Verification environment preflight | git --no-pager status --short && git --no-pager log -3 --oneline && git --no-pager diff --name-status HEAD^ HEAD && python --version && python -m pytest --version
⚠️ Verification environment preflight diagnostic output
Container verification could not start and local execution was not authorized: No trusted sandbox image is configured for microsoft/debugpy.

@bschnurr Bill Schnurr (bschnurr) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved via Review Center.

@bschnurr Bill Schnurr (bschnurr) added the review-auto:approved Automated review: no blocking findings (approval posted). label Aug 31, 2026

@rchiodo Rich Chiodo (rchiodo) left a comment

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.

@finnagin
Finn Womack (finnagin) merged commit e220805 into microsoft:main Sep 1, 2026
26 checks passed
shrewd-laidback palace (736-c41-2c1-e464fc974) pushed a commit to Swiss-Armed-Forces/Loom that referenced this pull request Sep 20, 2026
This MR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [debugpy](https://aka.ms/debugpy) ([source](https://github.com/microsoft/debugpy)) | dev | patch | `1.8.21` → `1.8.22` | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/microsoft/debugpy/badge)](https://securityscorecards.dev/viewer/?uri=github.com/microsoft/debugpy) |

---

### Release Notes

<details>
<summary>microsoft/debugpy (debugpy)</summary>

### [`v1.8.22`](https://github.com/microsoft/debugpy/releases/tag/v1.8.22): debugpy v1.8.22

[Compare Source](microsoft/debugpy@v1.8.21...v1.8.22)

##### Fixes

- Fix invalid type annotation in test\_pydev\_monkey comprehension by [@&#8203;pdepetro](https://github.com/pdepetro) in [#&#8203;2033](microsoft/debugpy#2033)
- Fix PEP 768 code injection SyntaxError when temp path contains backslashes by [@&#8203;rchiodo](https://github.com/rchiodo) with [@&#8203;Copilot](https://github.com/Copilot) in [#&#8203;2038](microsoft/debugpy#2038)
- Fix race between adapter connection publication and session attachment by [@&#8203;aperez](https://github.com/aperez) in [#&#8203;2049](microsoft/debugpy#2049)
- Fix debugger hang when expanding objects with blocking property getters ([#&#8203;2053](microsoft/debugpy#2053)) by [@&#8203;rchiodo](https://github.com/rchiodo) in [#&#8203;2055](microsoft/debugpy#2055)
- Fix duplicate stopped event when two threads hit a breakpoint at once by [@&#8203;aperez](https://github.com/aperez) in [#&#8203;2056](microsoft/debugpy#2056)
- Avoid exceptions in environment diagnostics by [@&#8203;rchiodo](https://github.com/rchiodo) in [#&#8203;2059](microsoft/debugpy#2059)
- Fix thread identity when the first traced call is another thread's is\_alive() by [@&#8203;aperez](https://github.com/aperez) in [#&#8203;2061](microsoft/debugpy#2061)
- Respect isolated mode when patching sys.path by [@&#8203;karandhaodiyal28-hash](https://github.com/karandhaodiyal28-hash) in [#&#8203;2050](microsoft/debugpy#2050)

##### Enhancements

- Add trigger\_exception\_handler() for post-mortem debugging of caught exceptions by [@&#8203;nshepperd](https://github.com/nshepperd) in [#&#8203;1996](microsoft/debugpy#1996)
- Add lldb attach-to-PID option for debugpy on Linux by [@&#8203;pdepetro](https://github.com/pdepetro) in [#&#8203;2052](microsoft/debugpy#2052)
- Populate hitBreakpointIds in the DAP stopped event by [@&#8203;aperez](https://github.com/aperez) in [#&#8203;2060](microsoft/debugpy#2060)
- Return the endpoint from listen() with the in-process adapter by [@&#8203;karandhaodiyal28-hash](https://github.com/karandhaodiyal28-hash) in [#&#8203;2051](microsoft/debugpy#2051)

##### Infrastructure work

- Add Dependabot configuration for pip and GitHub Actions by [@&#8203;rchiodo](https://github.com/rchiodo) in [#&#8203;2041](microsoft/debugpy#2041)
- Update vendored pydevd 3.4.1 -> 3.5.0 (maintenance refresh) by [@&#8203;rchiodo](https://github.com/rchiodo) in [#&#8203;2044](microsoft/debugpy#2044)
- Pin secure test dependency floors and drop EOL Python 3.9/3.8 by [@&#8203;rchiodo](https://github.com/rchiodo) in [#&#8203;2045](microsoft/debugpy#2045)
- Add more typing to debugpy and switch to 'standard' type checking mode by [@&#8203;rchiodo](https://github.com/rchiodo) in [#&#8203;1637](microsoft/debugpy#1637)
- Add debugpy release agent by [@&#8203;rchiodo](https://github.com/rchiodo) in [#&#8203;2062](microsoft/debugpy#2062)
- Pin GitHub Actions to full-length commit SHAs by [@&#8203;danfiedler-msft](https://github.com/danfiedler-msft) in [#&#8203;2063](microsoft/debugpy#2063)
- Add python 3.15 to tests by [@&#8203;finnagin](https://github.com/finnagin) in [#&#8203;2069](microsoft/debugpy#2069)

Thanks to [@&#8203;pdepetro](https://github.com/pdepetro), [@&#8203;rchiodo](https://github.com/rchiodo), [@&#8203;nshepperd](https://github.com/nshepperd), [@&#8203;aperez](https://github.com/aperez), [@&#8203;karandhaodiyal28-hash](https://github.com/karandhaodiyal28-hash), [@&#8203;danfiedler-msft](https://github.com/danfiedler-msft), and [@&#8203;finnagin](https://github.com/finnagin) for the commits.

**Full Changelog**: <microsoft/debugpy@v1.8.21...v1.8.22>

</details>

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xMDMuNSIsInVwZGF0ZWRJblZlciI6IjQ0LjEwMy41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

See merge request swiss-armed-forces/cyber-command/cea/loom!814
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.

3 participants