comparison mercurial/templateutil.py @ 50607:a6a17f799839

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:37:25 +0100
parents 82ef5410f2aa
children 832df74a488f
comparison
equal deleted inserted replaced
50606:90945014f4e4 50607:a6a17f799839
279 item = unwrapastype(context, mapping, item, self._keytype) 279 item = unwrapastype(context, mapping, item, self._keytype)
280 return item in self._values 280 return item in self._values
281 281
282 def getmember(self, context, mapping, key): 282 def getmember(self, context, mapping, key):
283 # TODO: maybe split hybrid list/dict types? 283 # TODO: maybe split hybrid list/dict types?
284 if not util.safehasattr(self._values, b'get'): 284 if not util.safehasattr(self._values, 'get'):
285 raise error.ParseError(_(b'not a dictionary')) 285 raise error.ParseError(_(b'not a dictionary'))
286 key = unwrapastype(context, mapping, key, self._keytype) 286 key = unwrapastype(context, mapping, key, self._keytype)
287 return self._wrapvalue(key, self._values.get(key)) 287 return self._wrapvalue(key, self._values.get(key))
288 288
289 def getmin(self, context, mapping): 289 def getmin(self, context, mapping):