Mercurial > hg
changeset 14948:32302480b402
cmdutil: use safehasattr instead of hasattr
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 25 Jul 2011 15:32:42 -0500 |
parents | 3aa34005a73d |
children | a4435770cf57 |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Mon Jul 25 15:09:17 2011 -0500 +++ b/mercurial/cmdutil.py Mon Jul 25 15:32:42 2011 -0500 @@ -161,7 +161,7 @@ if not pat or pat == '-': fp = writable and repo.ui.fout or repo.ui.fin - if hasattr(fp, 'fileno'): + if util.safehasattr(fp, 'fileno'): return os.fdopen(os.dup(fp.fileno()), mode) else: # if this fp can't be duped properly, return @@ -177,9 +177,9 @@ return getattr(self.f, attr) return wrappedfileobj(fp) - if hasattr(pat, 'write') and writable: + if util.safehasattr(pat, 'write') and writable: return pat - if hasattr(pat, 'read') and 'r' in mode: + if util.safehasattr(pat, 'read') and 'r' in mode: return pat return open(makefilename(repo, pat, node, total, seqno, revwidth, pathname), @@ -520,7 +520,7 @@ revwidth=revwidth, mode='ab') if fp != template: shouldclose = True - if fp != sys.stdout and hasattr(fp, 'name'): + if fp != sys.stdout and util.safehasattr(fp, 'name'): repo.ui.note("%s\n" % fp.name) fp.write("# HG changeset patch\n")