comparison mercurial/hgweb/request.py @ 49004: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 7eebe5630bcc
children 642e31cb55f0
comparison
equal deleted inserted replaced
49003:a0674e916fb6 49004:f254fc73d956
75 raise KeyError(b'multiple values for %r' % key) 75 raise KeyError(b'multiple values for %r' % key)
76 76
77 return vals[0] 77 return vals[0]
78 78
79 def asdictoflists(self): 79 def asdictoflists(self):
80 return {k: list(v) for k, v in pycompat.iteritems(self._items)} 80 return {k: list(v) for k, v in self._items.items()}
81 81
82 82
83 @attr.s(frozen=True) 83 @attr.s(frozen=True)
84 class parsedrequest(object): 84 class parsedrequest(object):
85 """Represents a parsed WSGI request. 85 """Represents a parsed WSGI request.
173 return encoding.strtolocal(s) 173 return encoding.strtolocal(s)
174 else: 174 else:
175 # This is what is documented to be used for os.environ on Unix. 175 # This is what is documented to be used for os.environ on Unix.
176 return pycompat.fsencode(s) 176 return pycompat.fsencode(s)
177 177
178 env = {tobytes(k): tobytes(v) for k, v in pycompat.iteritems(env)} 178 env = {tobytes(k): tobytes(v) for k, v in env.items()}
179 179
180 # Some hosting solutions are emulating hgwebdir, and dispatching directly 180 # Some hosting solutions are emulating hgwebdir, and dispatching directly
181 # to an hgweb instance using this environment variable. This was always 181 # to an hgweb instance using this environment variable. This was always
182 # checked prior to d7fd203e36cc; keep doing so to avoid breaking them. 182 # checked prior to d7fd203e36cc; keep doing so to avoid breaking them.
183 if not reponame: 183 if not reponame:
307 307
308 # HTTP_* keys contain HTTP request headers. The Headers structure should 308 # HTTP_* keys contain HTTP request headers. The Headers structure should
309 # perform case normalization for us. We just rewrite underscore to dash 309 # perform case normalization for us. We just rewrite underscore to dash
310 # so keys match what likely went over the wire. 310 # so keys match what likely went over the wire.
311 headers = [] 311 headers = []
312 for k, v in pycompat.iteritems(env): 312 for k, v in env.items():
313 if k.startswith(b'HTTP_'): 313 if k.startswith(b'HTTP_'):
314 headers.append((k[len(b'HTTP_') :].replace(b'_', b'-'), v)) 314 headers.append((k[len(b'HTTP_') :].replace(b'_', b'-'), v))
315 315
316 from . import wsgiheaders # avoid cycle 316 from . import wsgiheaders # avoid cycle
317 317