# HG changeset patch # User Augie Fackler # Date 2011-07-25 20:32:42 # Node ID 32302480b402385bbf60911a14cdc9ac74b3d640 # Parent 3aa34005a73df5d46cd81835b7faa2ed7591c1af cmdutil: use safehasattr instead of hasattr diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -161,7 +161,7 @@ def makefileobj(repo, pat, node=None, to 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 @@ def makefileobj(repo, pat, node=None, to 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 @@ def export(repo, revs, template='hg-%h.p 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")