comparison mercurial/dispatch.py @ 50569:fca08dd6223d

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:23:37 +0100
parents 2452843baf90
children b0c938f4141a
comparison
equal deleted inserted replaced
50568:82ef5410f2aa 50569:fca08dd6223d
329 def catchterm(*args): 329 def catchterm(*args):
330 raise error.SignalInterrupt 330 raise error.SignalInterrupt
331 331
332 ui = req.ui 332 ui = req.ui
333 try: 333 try:
334 for name in b'SIGBREAK', b'SIGHUP', b'SIGTERM': 334 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
335 num = getattr(signal, name, None) 335 num = getattr(signal, name, None)
336 if num: 336 if num:
337 signal.signal(num, catchterm) 337 signal.signal(num, catchterm)
338 except ValueError: 338 except ValueError:
339 pass # happens if called in a thread 339 pass # happens if called in a thread