##// END OF EJS Templates
util: make safehasattr() a pycompat function...
Yuya Nishihara -
r37117:6ca5f825 default
parent child Browse files
Show More
@@ -243,6 +243,8 b' if ispy3:'
243 243 def open(name, mode='r', buffering=-1, encoding=None):
244 244 return builtins.open(name, sysstr(mode), buffering, encoding)
245 245
246 safehasattr = _wrapattrfunc(builtins.hasattr)
247
246 248 def _getoptbwrapper(orig, args, shortlist, namelist):
247 249 """
248 250 Takes bytes arguments, converts them to unicode, pass them to
@@ -326,6 +328,11 b' else:'
326 328 def getdoc(obj):
327 329 return getattr(obj, '__doc__', None)
328 330
331 _notset = object()
332
333 def safehasattr(thing, attr):
334 return getattr(thing, attr, _notset) is not _notset
335
329 336 def _getoptbwrapper(orig, args, shortlist, namelist):
330 337 return orig(args, shortlist, namelist)
331 338
@@ -67,6 +67,7 b' empty = pycompat.empty'
67 67 httplib = pycompat.httplib
68 68 pickle = pycompat.pickle
69 69 queue = pycompat.queue
70 safehasattr = pycompat.safehasattr
70 71 socketserver = pycompat.socketserver
71 72 stderr = pycompat.stderr
72 73 stdin = pycompat.stdin
@@ -177,9 +178,6 b' except AttributeError:'
177 178
178 179 _notset = object()
179 180
180 def safehasattr(thing, attr):
181 return getattr(thing, attr, _notset) is not _notset
182
183 181 def _rapply(f, xs):
184 182 if xs is None:
185 183 # assume None means non-value of optional data
General Comments 0
You need to be logged in to leave comments. Login now