Skip to content

Commit 2dd6fb6

Browse files
adigieflub
authored andcommitted
Fix is_debugging for pydevd with cython (#146)
When `trace_func` comes from cython module, `inspect.getmodule` returns `None`. Fallback to getting module from `__class__` of `trace_func`.
1 parent 78cc24f commit 2dd6fb6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pytest_timeout.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,11 @@ def is_debugging(trace_func=None):
236236
return True
237237
if trace_func is None:
238238
trace_func = sys.gettrace()
239-
if trace_func and inspect.getmodule(trace_func):
240-
parts = inspect.getmodule(trace_func).__name__.split(".")
239+
trace_module = None
240+
if trace_func:
241+
trace_module = inspect.getmodule(trace_func) or inspect.getmodule(trace_func.__class__)
242+
if trace_module:
243+
parts = trace_module.__name__.split(".")
241244
for name in KNOWN_DEBUGGING_MODULES:
242245
if any(part.startswith(name) for part in parts):
243246
return True

0 commit comments

Comments
 (0)