diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2019-03-01 22:06:02 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2019-03-01 22:06:02 +0100 |
commit | a5d9314ce58200aa02d3464339f3cab5bd7ab77a (patch) | |
tree | 38117f330770b82ddb01eb29d336fab4b8dbff97 | |
parent | a80d9ce55d1d1f014f5d9aa5aed5e3a1010dd3b7 (diff) | |
parent | 02c019e4416cbacc5b228a7b5bd4c9d81fd6ced1 (diff) | |
download | cython-a5d9314ce58200aa02d3464339f3cab5bd7ab77a.tar.gz |
Merge branch '0.29.x'
-rw-r--r-- | CHANGES.rst | 10 | ||||
-rw-r--r-- | Cython/Compiler/Nodes.py | 3 | ||||
-rw-r--r-- | tests/run/coverage_nogil.srctree | 40 |
3 files changed, 32 insertions, 21 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index 4005c66cd..f165a74c0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -103,6 +103,16 @@ Other changes * Support for Python 2.6 was removed. +0.29.7 (2019-0?-??) +=================== + +Bugs fixed +---------- + +* Coverage reporting did not include the signature line of ``cdef`` functions. + (Github issue #1461) + + 0.29.6 (2019-02-27) =================== diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 89ef8a192..d8747a934 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2687,6 +2687,9 @@ class CFuncDefNode(FuncDefNode): self.generate_arg_none_check(arg, code) def generate_execution_code(self, code): + if code.globalstate.directives['linetrace']: + code.mark_pos(self.pos) + code.putln("") # generate line tracing code super(CFuncDefNode, self).generate_execution_code(code) if self.py_func_stat: self.py_func_stat.generate_execution_code(code) diff --git a/tests/run/coverage_nogil.srctree b/tests/run/coverage_nogil.srctree index 07da14a1f..053008cc2 100644 --- a/tests/run/coverage_nogil.srctree +++ b/tests/run/coverage_nogil.srctree @@ -25,19 +25,19 @@ plugins = Cython.Coverage # cython: linetrace=True # distutils: define_macros=CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1 -cdef int func1(int a, int b) nogil: - cdef int x # 5 - with gil: # 6 - x = 1 # 7 - cdef int c = func2(a) + b # 8 - return x + c # 9 +cdef int func1(int a, int b) nogil: # 4 + cdef int x # 5 + with gil: # 6 + x = 1 # 7 + cdef int c = func2(a) + b # 8 + return x + c # 9 -cdef int func2(int a) with gil: +cdef int func2(int a) with gil: # 12 return a * 2 # 13 -def call(int a, int b): +def call(int a, int b): # 16 a, b = b, a # 17 with nogil: # 18 result = func1(b, a) # 19 @@ -56,20 +56,18 @@ except ImportError: from coverage import coverage -import coverage_test_nogil - -assert not any(coverage_test_nogil.__file__.endswith(ext) - for ext in '.py .pyc .pyo .pyw .pyx .pxi'.split()), \ - coverage_test_nogil.__file__ - +def run_coverage(): + cov = coverage() + cov.start() -def run_coverage(module): + import coverage_test_nogil as module module_name = module.__name__ module_path = module_name + '.pyx' - - cov = coverage() - cov.start() + assert not any(module.__file__.endswith(ext) + for ext in '.py .pyc .pyo .pyw .pyx .pxi'.split()), \ + module.__file__ assert module.call(1, 2) == (1 * 2) + 2 + 1 + cov.stop() out = StringIO() @@ -84,10 +82,10 @@ def run_coverage(module): executed = set(exec_lines) - set(missing_lines) # check that everything that runs with the gil owned was executed - assert all(line in executed for line in [13, 17, 18, 20]), '%s / %s' % (exec_lines, missing_lines) + assert all(line in executed for line in [12, 13, 16, 17, 18, 20]), '%s / %s' % (exec_lines, missing_lines) # check that everything that runs in nogil sections was executed - assert all(line in executed for line in [6, 7, 8, 9]), '%s / %s' % (exec_lines, missing_lines) + assert all(line in executed for line in [4, 6, 7, 8, 9]), '%s / %s' % (exec_lines, missing_lines) if __name__ == '__main__': - run_coverage(coverage_test_nogil) + run_coverage() |