# HG changeset patch # User Pierre-Yves David # Date 2022-12-08 14:57:42 # 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 --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -355,6 +355,13 @@ def getdoc(obj: object) -> Optional[byte 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