##// END OF EJS Templates
cleanup: drop the `bytes` compatibility for attribute related function...
marmoute -
r52034:c845479f default
parent child Browse files
Show More
@@ -12,7 +12,6 b' This contains aliases to hide python ver'
12 import builtins
12 import builtins
13 import codecs
13 import codecs
14 import concurrent.futures as futures
14 import concurrent.futures as futures
15 import functools
16 import getopt
15 import getopt
17 import http.client as httplib
16 import http.client as httplib
18 import http.cookiejar as cookielib
17 import http.cookiejar as cookielib
@@ -352,26 +351,11 b' def getdoc(obj: object) -> Optional[byte'
352 return sysbytes(doc)
351 return sysbytes(doc)
353
352
354
353
355 def _wrapattrfunc(f):
356 @functools.wraps(f)
357 def w(object, name, *args):
358 if isinstance(name, bytes):
359 from . import util
360
361 msg = b'function "%s" take `str` as argument, not `bytes`'
362 fname = f.__name__.encode('ascii')
363 msg %= fname
364 util.nouideprecwarn(msg, b"6.6", stacklevel=2)
365 return f(object, sysstr(name), *args)
366
367 return w
368
369
370 # these wrappers are automagically imported by hgloader
354 # these wrappers are automagically imported by hgloader
371 delattr = _wrapattrfunc(builtins.delattr)
355 delattr = builtins.delattr
372 getattr = _wrapattrfunc(builtins.getattr)
356 getattr = builtins.getattr
373 hasattr = _wrapattrfunc(builtins.hasattr)
357 hasattr = builtins.hasattr
374 setattr = _wrapattrfunc(builtins.setattr)
358 setattr = builtins.setattr
375 xrange = builtins.range
359 xrange = builtins.range
376 unicode = str
360 unicode = str
377
361
@@ -386,7 +370,7 b' def open('
386 return builtins.open(name, sysstr(mode), buffering, encoding)
370 return builtins.open(name, sysstr(mode), buffering, encoding)
387
371
388
372
389 safehasattr = _wrapattrfunc(builtins.hasattr)
373 safehasattr = builtins.hasattr
390
374
391
375
392 def _getoptbwrapper(
376 def _getoptbwrapper(
General Comments 0
You need to be logged in to leave comments. Login now