Skip to content

vscode debugger is no longer detected #32

@Triconsult

Description

@Triconsult

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions