{"action":"created","issue":{"url":"https://api.github.com/repos/nedbat/coveragepy/issues/700","repository_url":"https://api.github.com/repos/nedbat/coveragepy","labels_url":"https://api.github.com/repos/nedbat/coveragepy/issues/700/labels{/name}","comments_url":"https://api.github.com/repos/nedbat/coveragepy/issues/700/comments","events_url":"https://api.github.com/repos/nedbat/coveragepy/issues/700/events","html_url":"https://github.com/nedbat/coveragepy/issues/700","id":357181089,"node_id":"MDU6SXNzdWUzNTcxODEwODk=","number":700,"title":"python 3.7: coverage fails with TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType","user":{"login":"diefans","id":513316,"node_id":"MDQ6VXNlcjUxMzMxNg==","avatar_url":"https://avatars3.githubusercontent.com/u/513316?v=4","gravatar_id":"","url":"https://api.github.com/users/diefans","html_url":"https://github.com/diefans","followers_url":"https://api.github.com/users/diefans/followers","following_url":"https://api.github.com/users/diefans/following{/other_user}","gists_url":"https://api.github.com/users/diefans/gists{/gist_id}","starred_url":"https://api.github.com/users/diefans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diefans/subscriptions","organizations_url":"https://api.github.com/users/diefans/orgs","repos_url":"https://api.github.com/users/diefans/repos","events_url":"https://api.github.com/users/diefans/events{/privacy}","received_events_url":"https://api.github.com/users/diefans/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-05T11:16:04Z","updated_at":"2018-09-05T14:29:38Z","closed_at":null,"author_association":"NONE","body":"```\r\nINTERNALERROR> Traceback (most recent call last):\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/_pytest/main.py\", line 178, in wrap_session\r\nINTERNALERROR>     session.exitstatus = doit(config, session) or 0\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/_pytest/main.py\", line 215, in _main\r\nINTERNALERROR>     config.hook.pytest_runtestloop(session=session)\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/pluggy/hooks.py\", line 258, in __call__\r\nINTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/pluggy/manager.py\", line 67, in _hookexec\r\nINTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/pluggy/manager.py\", line 61, in <lambda>\r\nINTERNALERROR>     firstresult=hook.spec_opts.get('firstresult'),\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/pluggy/callers.py\", line 196, in _multicall\r\nINTERNALERROR>     gen.send(outcome)\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/pytest_cov/plugin.py\", line 228, in pytest_runtestloop\r\nINTERNALERROR>     self.cov_controller.finish()\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/pytest_cov/engine.py\", line 167, in finish\r\nINTERNALERROR>     self.cov.stop()\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/coverage/control.py\", line 781, in save\r\nINTERNALERROR>     self.get_data()\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/coverage/control.py\", line 834, in get_data\r\nINTERNALERROR>     self._post_save_work()\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/coverage/control.py\", line 849, in _post_save_work\r\nINTERNALERROR>     self._warn_about_unmeasured_code(pkg)\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/coverage/control.py\", line 882, in _warn_about_unmeasured_code\r\nINTERNALERROR>     has_file = hasattr(mod, '__file__') and os.path.exists(mod.__file__)\r\nINTERNALERROR>   File \"/home/olli/.pyenv/versions/3.7.0/lib/python3.7/genericpath.py\", line 19, in exists\r\nINTERNALERROR>     os.stat(path)\r\nINTERNALERROR> TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType\r\n```\r\n\r\nIn Python 3.7 namespace packages seem to have a `__file__ == None` attribute, which leads to coverage not recognizing it.\r\n\r\nhttps://github.com/nedbat/coveragepy/blob/coverage-4.5.1x/coverage/control.py#L881\r\n\r\n```\r\n# ipython\r\nPython 3.7.0 (default, Jul  1 2018, 11:34:46)\r\nType 'copyright', 'credits' or 'license' for more information\r\nIPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.\r\nIn [1]: import com\r\nIn [2]: vars(com)\r\nOut[2]:\r\n{'__name__': 'com',\r\n '__doc__': None,\r\n '__package__': 'com',\r\n '__loader__': <_frozen_importlib_external._NamespaceLoader at 0x7f2944081588>,\r\n '__spec__': ModuleSpec(name='com', loader=<_frozen_importlib_external._NamespaceLoader object at 0x7f2944081588>, submodule_search_locations=_NamespacePath(['/home/code/ml/cookiecutter/foobar/src/com', '/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/com'])),\r\n '__file__': None,\r\n '__path__': _NamespacePath(['/home/code/ml/cookiecutter/foobar/src/com', '/home/olli/.pyenv/versions/3.7.0/envs/foobar/lib/python3.7/site-packages/com'])}\r\nIn [3]:\r\n```"},"comment":{"url":"https://api.github.com/repos/nedbat/coveragepy/issues/comments/418751995","html_url":"https://github.com/nedbat/coveragepy/issues/700#issuecomment-418751995","issue_url":"https://api.github.com/repos/nedbat/coveragepy/issues/700","id":418751995,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODc1MTk5NQ==","user":{"login":"diefans","id":513316,"node_id":"MDQ6VXNlcjUxMzMxNg==","avatar_url":"https://avatars3.githubusercontent.com/u/513316?v=4","gravatar_id":"","url":"https://api.github.com/users/diefans","html_url":"https://github.com/diefans","followers_url":"https://api.github.com/users/diefans/followers","following_url":"https://api.github.com/users/diefans/following{/other_user}","gists_url":"https://api.github.com/users/diefans/gists{/gist_id}","starred_url":"https://api.github.com/users/diefans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diefans/subscriptions","organizations_url":"https://api.github.com/users/diefans/orgs","repos_url":"https://api.github.com/users/diefans/repos","events_url":"https://api.github.com/users/diefans/events{/privacy}","received_events_url":"https://api.github.com/users/diefans/received_events","type":"User","site_admin":false},"created_at":"2018-09-05T14:29:38Z","updated_at":"2018-09-05T14:29:38Z","author_association":"NONE","body":"Something like this:\r\n```bash\r\n(\r\nexport DIR=/tmp/test_cov_ns\r\nrm -rf ${DIR}\r\nmkdir -p ${DIR}/com/foo\r\n\r\ncat > ${DIR}/com/foo/mod.py << EOF\r\ndef foobar():\r\n    pass\r\nEOF\r\n\r\ncat > ${DIR}/test_cov.py << EOF\r\ndef test_com():\r\n    import com.foo.mod\r\nEOF\r\n   \r\npython3.7 -m venv ${DIR}/venv\r\n${DIR}/venv/bin/pip install pytest coverage\r\ncd ${DIR}; ${DIR}/venv/bin/coverage run --source com.foo ${DIR}/venv/bin/pytest test_cov.py\r\n)\r\n```\r\n\r\nIn my original scenario one dependency provides a part of the namespace and I call coverage via `pytest --cov com` to get the error, but this does not work in this simple case (who knows)..."}}
{"actor":{"display_login":"diefans"}}