Mercurial > public > mercurial-scm > hg
diff mercurial/dispatch.py @ 50925:d718eddf01d9
safehasattr: drop usage in favor of hasattr
The two functions should now be equivalent at least in their usage in core.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 31 Aug 2023 23:56:15 +0200 |
parents | 9a322ccd2fdc |
children | 18c8c18993f0 |
line wrap: on
line diff
--- a/mercurial/dispatch.py Thu Dec 08 15:33:19 2022 +0100 +++ b/mercurial/dispatch.py Thu Aug 31 23:56:15 2023 +0200 @@ -107,7 +107,7 @@ def _flushstdio(ui, err): status = None # In all cases we try to flush stdio streams. - if util.safehasattr(ui, 'fout'): + if hasattr(ui, 'fout'): assert ui is not None # help pytype assert ui.fout is not None # help pytype try: @@ -116,7 +116,7 @@ err = e status = -1 - if util.safehasattr(ui, 'ferr'): + if hasattr(ui, 'ferr'): assert ui is not None # help pytype assert ui.ferr is not None # help pytype try: @@ -170,7 +170,7 @@ "newline": "\n", "line_buffering": sys.stdout.line_buffering, } - if util.safehasattr(sys.stdout, "write_through"): + if hasattr(sys.stdout, "write_through"): # pytype: disable=attribute-error kwargs["write_through"] = sys.stdout.write_through # pytype: enable=attribute-error @@ -183,7 +183,7 @@ "newline": "\n", "line_buffering": sys.stderr.line_buffering, } - if util.safehasattr(sys.stderr, "write_through"): + if hasattr(sys.stderr, "write_through"): # pytype: disable=attribute-error kwargs["write_through"] = sys.stderr.write_through # pytype: enable=attribute-error @@ -520,7 +520,7 @@ def aliasargs(fn, givenargs): args = [] # only care about alias 'args', ignore 'args' set by extensions.wrapfunction - if not util.safehasattr(fn, '_origfunc'): + if not hasattr(fn, '_origfunc'): args = getattr(fn, 'args', args) if args: cmd = b' '.join(map(procutil.shellquote, args)) @@ -708,7 +708,7 @@ } if name not in adefaults: raise AttributeError(name) - if self.badalias or util.safehasattr(self, 'shell'): + if self.badalias or hasattr(self, 'shell'): return adefaults[name] return getattr(self.fn, name) @@ -734,7 +734,7 @@ self.name, self.definition, ) - if util.safehasattr(self, 'shell'): + if hasattr(self, 'shell'): return self.fn(ui, *args, **opts) else: try: @@ -1024,7 +1024,7 @@ cmd = aliases[0] fn = entry[0] - if cmd and util.safehasattr(fn, 'shell'): + if cmd and hasattr(fn, 'shell'): # shell alias shouldn't receive early options which are consumed by hg _earlyopts, args = _earlysplitopts(args) d = lambda: fn(ui, *args[1:])