Mercurial > public > mercurial-scm > hg
comparison mercurial/lsprof.py @ 48913:f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
pycompat.iteritems() just calls .items().
This commit applies a regular expression search and replace to convert
simple instances of pycompat.iteritems() with .items(). There are still
a handful of calls to pycompat.iteritems() remaining. But these all have
more complicated expressions that I wasn't comfortable performing an
automated replace on. In addition, some simple replacements were withheld
because they broke pytype. These will be handled by their own changesets.
Differential Revision: https://phab.mercurial-scm.org/D12318
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 03 Mar 2022 18:28:30 -0800 |
parents | 6000f5b25c9b |
children | 32ac127c999f |
comparison
equal
deleted
inserted
replaced
48912:a0674e916fb6 | 48913:f254fc73d956 |
---|---|
1 import _lsprof | 1 import _lsprof |
2 import sys | 2 import sys |
3 | 3 |
4 from .pycompat import getattr | 4 from .pycompat import getattr |
5 from . import pycompat | |
6 | 5 |
7 Profiler = _lsprof.Profiler | 6 Profiler = _lsprof.Profiler |
8 | 7 |
9 # PyPy doesn't expose profiler_entry from the module. | 8 # PyPy doesn't expose profiler_entry from the module. |
10 profiler_entry = getattr(_lsprof, 'profiler_entry', None) | 9 profiler_entry = getattr(_lsprof, 'profiler_entry', None) |
122 code = code.encode('latin-1') | 121 code = code.encode('latin-1') |
123 return code | 122 return code |
124 try: | 123 try: |
125 mname = _fn2mod[code.co_filename] | 124 mname = _fn2mod[code.co_filename] |
126 except KeyError: | 125 except KeyError: |
127 for k, v in list(pycompat.iteritems(sys.modules)): | 126 for k, v in list(sys.modules.items()): |
128 if v is None: | 127 if v is None: |
129 continue | 128 continue |
130 if not isinstance(getattr(v, '__file__', None), str): | 129 if not isinstance(getattr(v, '__file__', None), str): |
131 continue | 130 continue |
132 if v.__file__.startswith(code.co_filename): | 131 if v.__file__.startswith(code.co_filename): |