# HG changeset patch # User Pierre-Yves David # Date 1670511462 -3600 # Node ID 9bffc6c4e4c57743a2c10a19fb06972adc7dbaf2 # Parent c642c03969ffe293352e1e2e91655ecf87cd68dc pycompat: deprecate using bytes Python2 has been dropped for a while, so lets comply to the signature of the global function. This open the way to drop the use of `pycompat.getattr` and company, and, especially, the associated `util.safehasattr`. diff -r c642c03969ff -r 9bffc6c4e4c5 mercurial/pycompat.py --- a/mercurial/pycompat.py Thu Aug 31 02:41:33 2023 +0200 +++ b/mercurial/pycompat.py Thu Dec 08 15:57:42 2022 +0100 @@ -355,6 +355,13 @@ def _wrapattrfunc(f): @functools.wraps(f) def w(object, name, *args): + if isinstance(name, bytes): + from . import util + + msg = b'function "%s" take `str` as argument, not `bytes`' + fname = f.__name__.encode('ascii') + msg %= fname + util.nouideprecwarn(msg, b"6.6", stacklevel=2) return f(object, sysstr(name), *args) return w