Hi Mark, All,

Following up on my earlier thread about axdebug being disabled on Python 3.11+ ("Debugging extensions (axdebug) module does not exist").

I've tracked down the root cause and submitted a fix: https://github.com/mhammond/pywin32/pull/2723

The error message comes from framework.py line 763 — when SetScriptSite creates the DebugManager, it tries to import axdebug. If axdebug.pyd doesn't exist (because the build was skipped on 3.11+), the ImportError is caught and debugging is silently disabled.

Root cause:

Python 3.11 (PEP 523) made PyFrameObject an opaque type :
- C extensions can no longer access struct fields like frame->f_code, frame->f_back, or frame->f_trace directly. - AXDebug.cpp's SetThreadStateTrace() relied on direct struct access to walk the frame chain and set trace functions, so it failed to compile on 3.11+.
     -  PyWin32: The module was disabled in setup.py as a workaround.

The fix replaces direct struct access with the official getter APIs that Python provides for opaque frame access:

    frame->f_code          ->  PyFrame_GetCode(frame)
    frame->f_back          ->  PyFrame_GetBack(frame)
frame->f_trace = fn -> PyObject_SetAttrString(frame, "f_trace", fn)
    state->frame             ->  PyThreadState_GetFrame(state)

These APIs are stable across Python 3.11-3.14. The pre-3.11 code path is preserved with #if guards, so older Python versions are unaffected.

This PR also fixed a long-standing bug in adb.py where step-over (F10) would not stop after returning from a function — dispatch_return now promotes stopframe to the caller frame.

Minimal change — 3 files, +33/-20 lines. Tested on Python 3.14.2 with a custom ActiveX Script Host exercising the full debug path. I also built a DAP (Debug Adapter Protocol) bridge that enables VS Code to debug ActiveX-hosted Python scripts — breakpoints, step-into, step-over, step-out, variable inspection, and watch expressions all work correctly through the fixed axdebug module.

Would appreciate your review when you get a chance.

Best,
Wuping


------ Original Message ------
From "Wuping Xin" <[email protected]>
To "Mark Hammond" <[email protected]>; "[email protected]" <[email protected]>
Date 3/3/2025 11:07:06 AM
Subject Re[2]: [python-win32] Python Active Scripting Debug


Thank you Mark for the response.  Appreciate your input.

Best
Wuping

------ Original Message ------
From "Mark Hammond" <[email protected]>
To "Wuping Xin" <[email protected]>; "[email protected]" <[email protected]>
Date 3/3/2025 10:24:18 AM
Subject Re: [python-win32] Python Active Scripting Debug

It has been quite a few years since anyone worked on that, but in general it should "just work" if everything is registered correctly. There are a few demos which should make OK starting points, and ensuring everything is registered for debugging, and debugging output can be seen (typically via win32traceutil) must be done. Unfortunately, I'm not aware of anyone trying to use the VS tools in this way.

Good luck,

Mark

On 2025-02-28 8:54 p.m., Wuping Xin via python-win32 wrote:
Hi All,

I am trying to debug Python Active Scripting, using Visual Studio. I am 100% sure it should work but I just cannot get it work.

I've installed the debug symbols of the Python version, and installed Visual Studio Python Native Development tools.

I also set the "Debugging" registry entry for the ActivePy from 0 to 1.

I am able to attach the Python script to the PythonActiveScript host.

But, I just got the following message:

Debugging extensions (axdebug) module does not exist - debugging is disabled..


Any insights?

Thank you in advance!

W.X.
_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32
_______________________________________________
python-win32 mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-win32.python.org
Member address: [email protected]

Reply via email to