New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cython.Coverage produces error when using gevent #2776

Open
wjsi opened this Issue Jan 2, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@wjsi
Copy link

wjsi commented Jan 2, 2019

Hi,

I build a simple pyx with gevent module (https://github.com/wjsi/test_cython_cov/blob/master/test_cov.pyx) and try to use Cython.Coverage to get code coverage, it produces an error when coverage report is executed:

$ coverage run test_file.py
$ coverage report
Plugin 'Cython.Coverage.Plugin' did not provide a file reporter for '/Users/wenjun.swj/miniconda3/lib/python3.7/site-packages/gevent/_hub_local.py'.

When gevent is removed, for instance, replaced with time module, no errors raised and the report is shown normally.

I uploaded all test files in https://github.com/wjsi/test_cython_cov. I'm running on MacOS 10.14 with Anaconda Python 3.7.1, cython==0.29.2 and coverage==4.5.2.

@wjsi wjsi referenced a pull request that will close this issue Jan 5, 2019

Open

Fix inconsistency between traced files and reported files #2784

@scoder

This comment has been minimized.

Copy link
Contributor

scoder commented Jan 11, 2019

Thanks for the report. I have no idea what gevent does here, so this needs more investigation to find out how this differs from normal CPython behaviour and what can be done to make this work.

@wjsi

This comment has been minimized.

Copy link

wjsi commented Jan 11, 2019

@scoder during compilation, gevent compiles its _hub_local.py in https://github.com/gevent/gevent/blob/master/setup.py#L117 using cython into __hub_local.so and then import the compiled lib on the bottom of https://github.com/gevent/gevent/blob/master/src/gevent/_hub_local.py#L101 to get itself accelerated, which produces a _hub_local.c with path gevent/src/gevent/_hub_local.c. However, when installed as a wheel package, the path becomes gevent/_hub_local.c, therefore Cython.Coverage cannot spot the path of _hub_local.py. When creating the tracer, it reports no errors. However, when creating the reporter, no source file can be spotted and the error occurs.
I've written a test case to reproduce this error in #2784.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment