changeset 50924:9bffc6c4e4c5

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`.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 08 Dec 2022 15:57:42 +0100
parents c642c03969ff
children 13eab1a5db78
files mercurial/pycompat.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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