Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
7d6b784f
Commit
7d6b784f
authored
7 years ago
by
Dmitry Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test disabling of tracing returning None from trace function
parent
17e63f6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
tests/run/line_trace.pyx
tests/run/line_trace.pyx
+32
-1
No files found.
tests/run/line_trace.pyx
View file @
7d6b784f
...
...
@@ -49,7 +49,7 @@ cdef int trace_trampoline(PyObject* _traceobj, PyFrameObject* _frame, int what,
if
result
is
None
:
PyEval_SetTrace
(
NULL
,
None
)
return
-
1
return
0
else
:
return
0
...
...
@@ -87,6 +87,16 @@ def _create__failing_line_trace_func(trace):
return
_trace_func
return
_trace_func
def
_create_disable_tracing
(
trace
):
func
=
_create_trace_func
(
trace
)
def
_trace_func
(
frame
,
event
,
arg
):
if
frame
.
f_lineno
-
frame
.
f_code
.
co_firstlineno
==
2
:
return
None
func
(
frame
,
event
,
arg
)
return
_trace_func
return
_trace_func
def
cy_add
(
a
,
b
):
x
=
a
+
b
# 1
...
...
@@ -198,3 +208,24 @@ def fail_on_line_trace(fail_func):
else
:
assert
x
==
5
return
trace
def
disable_trace
(
func
,
*
args
):
"""
>>> def py_add(a,b):
... x = a+b
... return x
>>> disable_trace(py_add, 1, 2)
[('call', 0), ('line', 1)]
>>> disable_trace(cy_add, 1, 2)
[('call', 0), ('line', 1)]
>>> disable_trace(cy_add_with_nogil, 1, 2)
[('call', 0), ('line', 1)]
"""
trace
=
[]
PyEval_SetTrace
(
<
Py_tracefunc
>
trace_trampoline
,
_create_disable_tracing
(
trace
))
try
:
func
(
*
args
)
finally
:
PyEval_SetTrace
(
NULL
,
None
)
return
trace
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment