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