133 """Report support for a Python file.""" |
133 """Report support for a Python file.""" |
134 |
134 |
135 def __init__(self, morf, coverage=None): |
135 def __init__(self, morf, coverage=None): |
136 self.coverage = coverage |
136 self.coverage = coverage |
137 |
137 |
138 if hasattr(morf, '__file__'): |
138 if hasattr(morf, '__file__') and morf.__file__: |
139 filename = morf.__file__ |
139 filename = morf.__file__ |
140 elif isinstance(morf, types.ModuleType): |
140 elif isinstance(morf, types.ModuleType): |
141 # A module should have had .__file__, otherwise we can't use it. |
141 # A module should have had .__file__, otherwise we can't use it. |
142 # This could be a PEP-420 namespace package. |
142 # This could be a PEP-420 namespace package. |
143 raise CoverageException("Module {0} has no file".format(morf)) |
143 raise CoverageException("Module {0} has no file".format(morf)) |