Skip to content

Commit

Permalink
Fix is_debugging for pydevd with cython (#146)
Browse files Browse the repository at this point in the history
When `trace_func` comes from cython module, `inspect.getmodule`
returns `None`. Fallback to getting module from `__class__` of
`trace_func`.
  • Loading branch information
adigie authored and flub committed Oct 19, 2023
1 parent 78cc24f commit 2dd6fb6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pytest_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,11 @@ def is_debugging(trace_func=None):
return True
if trace_func is None:
trace_func = sys.gettrace()
if trace_func and inspect.getmodule(trace_func):
parts = inspect.getmodule(trace_func).__name__.split(".")
trace_module = None
if trace_func:
trace_module = inspect.getmodule(trace_func) or inspect.getmodule(trace_func.__class__)
if trace_module:
parts = trace_module.__name__.split(".")
for name in KNOWN_DEBUGGING_MODULES:
if any(part.startswith(name) for part in parts):
return True
Expand Down

0 comments on commit 2dd6fb6

Please sign in to comment.