Mercurial > public > mercurial-scm > hg
comparison mercurial/dispatch.py @ 50570:9a322ccd2fdc
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:24:16 +0100 |
parents | 35e420abaef3 |
children | d718eddf01d9 |
comparison
equal
deleted
inserted
replaced
50569:35e420abaef3 | 50570:9a322ccd2fdc |
---|---|
1022 return | 1022 return |
1023 | 1023 |
1024 cmd = aliases[0] | 1024 cmd = aliases[0] |
1025 fn = entry[0] | 1025 fn = entry[0] |
1026 | 1026 |
1027 if cmd and util.safehasattr(fn, b'shell'): | 1027 if cmd and util.safehasattr(fn, 'shell'): |
1028 # shell alias shouldn't receive early options which are consumed by hg | 1028 # shell alias shouldn't receive early options which are consumed by hg |
1029 _earlyopts, args = _earlysplitopts(args) | 1029 _earlyopts, args = _earlysplitopts(args) |
1030 d = lambda: fn(ui, *args[1:]) | 1030 d = lambda: fn(ui, *args[1:]) |
1031 return lambda: runcommand( | 1031 return lambda: runcommand( |
1032 lui, None, cmd, args[:1], ui, options, d, [], {} | 1032 lui, None, cmd, args[:1], ui, options, d, [], {} |