Mercurial > hg
changeset 51141:c845479fc64d
cleanup: drop the `bytes` compatibility for attribute related function
We can rely on the builtins directly now.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 08 Nov 2023 22:27:32 +0100 |
parents | eda075d7b2ac |
children | 204af2aa4931 |
files | mercurial/pycompat.py |
diffstat | 1 files changed, 5 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/pycompat.py Wed Nov 08 22:20:58 2023 +0100 +++ b/mercurial/pycompat.py Wed Nov 08 22:27:32 2023 +0100 @@ -12,7 +12,6 @@ import builtins import codecs import concurrent.futures as futures -import functools import getopt import http.client as httplib import http.cookiejar as cookielib @@ -352,26 +351,11 @@ return sysbytes(doc) -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 - - # these wrappers are automagically imported by hgloader -delattr = _wrapattrfunc(builtins.delattr) -getattr = _wrapattrfunc(builtins.getattr) -hasattr = _wrapattrfunc(builtins.hasattr) -setattr = _wrapattrfunc(builtins.setattr) +delattr = builtins.delattr +getattr = builtins.getattr +hasattr = builtins.hasattr +setattr = builtins.setattr xrange = builtins.range unicode = str @@ -386,7 +370,7 @@ return builtins.open(name, sysstr(mode), buffering, encoding) -safehasattr = _wrapattrfunc(builtins.hasattr) +safehasattr = builtins.hasattr def _getoptbwrapper(