##// END OF EJS Templates
dispatch: use safehasattr instead of hasattr
Augie Fackler -
r14950:144e9742 default
parent child Browse files
Show More
@@ -159,16 +159,16 b' def _runcatch(req):'
159 elif m in "zlib".split():
159 elif m in "zlib".split():
160 ui.warn(_("(is your Python install correct?)\n"))
160 ui.warn(_("(is your Python install correct?)\n"))
161 except IOError, inst:
161 except IOError, inst:
162 if hasattr(inst, "code"):
162 if util.safehasattr(inst, "code"):
163 ui.warn(_("abort: %s\n") % inst)
163 ui.warn(_("abort: %s\n") % inst)
164 elif hasattr(inst, "reason"):
164 elif util.safehasattr(inst, "reason"):
165 try: # usually it is in the form (errno, strerror)
165 try: # usually it is in the form (errno, strerror)
166 reason = inst.reason.args[1]
166 reason = inst.reason.args[1]
167 except (AttributeError, IndexError):
167 except (AttributeError, IndexError):
168 # it might be anything, for example a string
168 # it might be anything, for example a string
169 reason = inst.reason
169 reason = inst.reason
170 ui.warn(_("abort: error: %s\n") % reason)
170 ui.warn(_("abort: error: %s\n") % reason)
171 elif hasattr(inst, "args") and inst.args[0] == errno.EPIPE:
171 elif util.safehasattr(inst, "args") and inst.args[0] == errno.EPIPE:
172 if ui.debugflag:
172 if ui.debugflag:
173 ui.warn(_("broken pipe\n"))
173 ui.warn(_("broken pipe\n"))
174 elif getattr(inst, "strerror", None):
174 elif getattr(inst, "strerror", None):
@@ -338,7 +338,7 b' class cmdalias(object):'
338 ui.debug("alias '%s' shadows command '%s'\n" %
338 ui.debug("alias '%s' shadows command '%s'\n" %
339 (self.name, self.cmdname))
339 (self.name, self.cmdname))
340
340
341 if hasattr(self, 'shell'):
341 if util.safehasattr(self, 'shell'):
342 return self.fn(ui, *args, **opts)
342 return self.fn(ui, *args, **opts)
343 else:
343 else:
344 try:
344 try:
@@ -506,7 +506,7 b' def _checkshellalias(lui, ui, args):'
506 cmd = aliases[0]
506 cmd = aliases[0]
507 fn = entry[0]
507 fn = entry[0]
508
508
509 if cmd and hasattr(fn, 'shell'):
509 if cmd and util.safehasattr(fn, 'shell'):
510 d = lambda: fn(ui, *args[1:])
510 d = lambda: fn(ui, *args[1:])
511 return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, [], {})
511 return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, [], {})
512
512
General Comments 0
You need to be logged in to leave comments. Login now