DebugClients/Python/coverage/codeunit.py

changeset 4385
599681bf149a
parent 3499
f2d4b02c7e88
equal deleted inserted replaced
4384:04896c4a5a8e 4385:599681bf149a
1 """Code unit (module) handling for Coverage.""" 1 """Code unit (module) handling for Coverage."""
2 2
3 import glob, os 3 import glob, os, sys
4 4
5 from .backward import open_source, string_class, StringIO 5 from .backward import open_source, string_class, StringIO
6 from .misc import CoverageException 6 from .misc import CoverageException
7 7
8 8
55 if f.endswith('.pyc') or f.endswith('.pyo'): 55 if f.endswith('.pyc') or f.endswith('.pyo'):
56 f = f[:-1] 56 f = f[:-1]
57 elif f.endswith('$py.class'): # Jython 57 elif f.endswith('$py.class'): # Jython
58 f = f[:-9] + ".py" 58 f = f[:-9] + ".py"
59 self.filename = self.file_locator.canonical_filename(f) 59 self.filename = self.file_locator.canonical_filename(f)
60 if isinstance(self.filename, unicode):
61 self.filename = self.filename.encode(sys.getfilesystemencoding())
60 62
61 if hasattr(morf, '__name__'): 63 if hasattr(morf, '__name__'):
62 n = modname = morf.__name__ 64 n = modname = morf.__name__
63 self.relative = True 65 self.relative = True
64 else: 66 else:
65 n = os.path.splitext(morf)[0] 67 n = os.path.splitext(morf)[0]
66 rel = self.file_locator.relative_filename(n) 68 rel = self.file_locator.relative_filename(n)
69 if isinstance(rel, unicode):
70 rel = rel.encode(sys.getfilesystemencoding())
67 if os.path.isabs(n): 71 if os.path.isabs(n):
68 self.relative = (rel != n) 72 self.relative = (rel != n)
69 else: 73 else:
70 self.relative = True 74 self.relative = True
71 n = rel 75 n = rel

eric ide

mercurial