alt-pytest-asyncio icon indicating copy to clipboard operation
alt-pytest-asyncio copied to clipboard

vscode debugger is no longer detected

Open Triconsult opened this issue 5 months ago • 4 comments

The code that checks whether a debugger is active has become outdated. Currently it only checks sys.gettrace(), but apparently python has introduced a new API for this. The correct code should now look like this (stolen from this StackOverflow answer):

import sys

def debug_enabled():
    try:
        if sys.gettrace() is not None:
            return True
    except AttributeError:
        pass

    try:
        if sys.monitoring.get_tool(sys.monitoring.DEBUGGER_ID) is not None:
            return True
    except AttributeError:
        pass

    return False

I would appreciate if this change could be added to version 7 of this plugin as well. I have quite a few projects that need to be tested with python 3.10, and v8+ all require at least python 3.11.

Triconsult avatar Nov 12 '25 16:11 Triconsult