##// END OF EJS Templates
py3: provide (del|get|has|set)attr wrappers that accepts bytes...
Yuya Nishihara -
r29799:45fa8de4 default
parent child Browse files
Show More
@@ -31,8 +31,22 b' else:'
31
31
32 if sys.version_info[0] >= 3:
32 if sys.version_info[0] >= 3:
33 import builtins
33 import builtins
34 import functools
34 builtins.xrange = range
35 builtins.xrange = range
35
36
37 def _wrapattrfunc(f):
38 @functools.wraps(f)
39 def w(object, name, *args):
40 if isinstance(name, bytes):
41 name = name.decode(u'utf-8')
42 return f(object, name, *args)
43 return w
44
45 delattr = _wrapattrfunc(builtins.delattr)
46 getattr = _wrapattrfunc(builtins.getattr)
47 hasattr = _wrapattrfunc(builtins.hasattr)
48 setattr = _wrapattrfunc(builtins.setattr)
49
36 stringio = io.StringIO
50 stringio = io.StringIO
37 empty = _queue.Empty
51 empty = _queue.Empty
38 queue = _queue.Queue
52 queue = _queue.Queue
General Comments 0
You need to be logged in to leave comments. Login now