Skip to content

Commit ba57de2

Browse files
committed
Align the pure python implementation with the cython one - Event doesn't require a tracer instance.
1 parent 9a62bb6 commit ba57de2

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

src/hunter/event.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .const import SYS_PREFIX_PATHS
1212
from .util import CYTHON_SUFFIX_RE
1313
from .util import LEADING_WHITESPACE_RE
14-
from .util import MISSING
1514
from .util import cached_property
1615
from .util import get_func_in_mro
1716
from .util import get_main_thread
@@ -47,23 +46,10 @@ def __init__(
4746
frame,
4847
kind,
4948
arg,
50-
tracer=None,
51-
depth=None,
52-
calls=None,
53-
threading_support=MISSING,
49+
depth,
50+
calls,
51+
threading_support,
5452
):
55-
if tracer is None:
56-
if depth is None:
57-
raise TypeError('Missing argument: depth (required because tracer was not given).')
58-
if calls is None:
59-
raise TypeError('Missing argument: calls (required because tracer was not given).')
60-
if threading_support is MISSING:
61-
raise TypeError('Missing argument: threading_support (required because tracer was not given).')
62-
else:
63-
depth = tracer.depth
64-
calls = tracer.calls
65-
threading_support = tracer.threading_support
66-
6753
#: The original Frame object.
6854
#:
6955
#: .. note::

src/hunter/tracer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __call__(self, frame, kind, arg):
7878
if self._handler is not None:
7979
if kind == 'return' and self.depth > 0:
8080
self.depth -= 1
81-
event = Event(frame, kind, arg, self)
81+
event = Event(frame, kind, arg, self.depth, self.calls, self.threading_support)
8282
try:
8383
self._handler(event)
8484
except Exception as exc:

tests/test_predicates.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def mockevent():
5050
sys._getframe(0),
5151
2 if '_event' in hunter.Event.__module__ else 'line',
5252
None,
53-
hunter.Tracer(),
53+
0,
54+
0,
55+
False,
5456
)
5557

5658

0 commit comments

Comments
 (0)