equal
deleted
inserted
replaced
2 |
2 |
3 import _lsprof |
3 import _lsprof |
4 import sys |
4 import sys |
5 |
5 |
6 from .pycompat import getattr |
6 from .pycompat import getattr |
|
7 from . import pycompat |
7 |
8 |
8 Profiler = _lsprof.Profiler |
9 Profiler = _lsprof.Profiler |
9 |
10 |
10 # PyPy doesn't expose profiler_entry from the module. |
11 # PyPy doesn't expose profiler_entry from the module. |
11 profiler_entry = getattr(_lsprof, 'profiler_entry', None) |
12 profiler_entry = getattr(_lsprof, 'profiler_entry', None) |
123 code = code.encode('latin-1') |
124 code = code.encode('latin-1') |
124 return code |
125 return code |
125 try: |
126 try: |
126 mname = _fn2mod[code.co_filename] |
127 mname = _fn2mod[code.co_filename] |
127 except KeyError: |
128 except KeyError: |
128 for k, v in list(sys.modules.iteritems()): |
129 for k, v in list(pycompat.iteritems(sys.modules)): |
129 if v is None: |
130 if v is None: |
130 continue |
131 continue |
131 if not isinstance(getattr(v, '__file__', None), str): |
132 if not isinstance(getattr(v, '__file__', None), str): |
132 continue |
133 continue |
133 if v.__file__.startswith(code.co_filename): |
134 if v.__file__.startswith(code.co_filename): |