DebugClients/Python/coverage/execfile.py

changeset 5051
3586ebd9fac8
parent 4491
0d8612e24fef
equal deleted inserted replaced
5047:04e5dfbd3f3d 5051:3586ebd9fac8
8 import sys 8 import sys
9 import types 9 import types
10 10
11 from coverage.backward import BUILTINS 11 from coverage.backward import BUILTINS
12 from coverage.backward import PYC_MAGIC_NUMBER, imp, importlib_util_find_spec 12 from coverage.backward import PYC_MAGIC_NUMBER, imp, importlib_util_find_spec
13 from coverage.misc import ExceptionDuringRun, NoCode, NoSource 13 from coverage.misc import ExceptionDuringRun, NoCode, NoSource, isolate_module
14 from coverage.phystokens import compile_unicode 14 from coverage.phystokens import compile_unicode
15 from coverage.python import get_python_source 15 from coverage.python import get_python_source
16
17 os = isolate_module(os)
16 18
17 19
18 class DummyLoader(object): 20 class DummyLoader(object):
19 """A shim for the pep302 __loader__, emulating pkgutil.ImpLoader. 21 """A shim for the pep302 __loader__, emulating pkgutil.ImpLoader.
20 22
37 raise NoSource(str(err)) 39 raise NoSource(str(err))
38 if not spec: 40 if not spec:
39 raise NoSource("No module named %r" % (modulename,)) 41 raise NoSource("No module named %r" % (modulename,))
40 pathname = spec.origin 42 pathname = spec.origin
41 packagename = spec.name 43 packagename = spec.name
42 if pathname.endswith("__init__.py"): 44 if pathname.endswith("__init__.py") and not modulename.endswith("__init__"):
43 mod_main = modulename + ".__main__" 45 mod_main = modulename + ".__main__"
44 spec = importlib_util_find_spec(mod_main) 46 spec = importlib_util_find_spec(mod_main)
45 if not spec: 47 if not spec:
46 raise NoSource( 48 raise NoSource(
47 "No module named %s; " 49 "No module named %s; "

eric ide

mercurial