comparison mercurial/httppeer.py @ 50579:b23b3ef38ba1

safehasattr: pass attribute name as string instead of bytes This is a step toward replacing `util.safehasattr` usage with plain `hasattr`. The builtin function behave poorly in Python2 but this was fixed in Python3. These change are done one by one as they tend to have a small odd to trigger puzzling breackage.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 02 Feb 2023 17:28:07 +0100
parents 35b274cba81d
children 60f9602b413e
comparison
equal deleted inserted replaced
50578:35b274cba81d 50579:b23b3ef38ba1
178 q += sorted(args.items()) 178 q += sorted(args.items())
179 179
180 qs = b'?%s' % urlreq.urlencode(q) 180 qs = b'?%s' % urlreq.urlencode(q)
181 cu = b"%s%s" % (repobaseurl, qs) 181 cu = b"%s%s" % (repobaseurl, qs)
182 size = 0 182 size = 0
183 if util.safehasattr(data, b'length'): 183 if util.safehasattr(data, 'length'):
184 size = data.length 184 size = data.length
185 elif data is not None: 185 elif data is not None:
186 size = len(data) 186 size = len(data)
187 if data is not None and 'Content-Type' not in headers: 187 if data is not None and 'Content-Type' not in headers:
188 headers['Content-Type'] = 'application/mercurial-0.1' 188 headers['Content-Type'] = 'application/mercurial-0.1'