Describe the bug
Unlike python -m, inside coverage run -m it turns out __spec__ is unexpectedly None.
$ python --version
Python 3.5.6 :: Anaconda, Inc.
$ coverage --version
Coverage.py, version 4.5.1 with C extension
Documentation at https://coverage.readthedocs.io
$ cat foo.py
$ python -m foo # Behaves as expected
$ coverage run -m foo # Observe __spec__ is None
Traceback (most recent call last):
File "/nas/dft/ire/rhys/Build/liquidmetal-debt/foo.py", line 2, in <module>
AttributeError: 'NoneType' object has no attribute 'name'
Coverage.py warning: No data was collected. (no-data-collected)
The text was updated successfully, but these errors were encountered:
The special global variables name, spec, file, cached, loader and package are set in the globals dictionary before the module code is executed (Note that this is a minimal set of variables - other variables may be set implicitly as an interpreter implementation detail).
Discussion there around PEP 451 suggests the spec handling may only be correct post Python 3.4. I've not tested anything in this manner.