[PATCH 2 of 3 RFC] Remove all uses of hasattr(a, b) in favor of getattr(a, b, None)

Martin Geisler mg at lazybytes.net
Sun Mar 13 06:24:24 CDT 2011


Benoit Boissinot <bboissin at gmail.com> writes:

> On Tue, Mar 8, 2011 at 9:36 AM, Martin Geisler <mg at aragost.com> wrote:
>>
>> Would it not make sense to overwrite __builtin__.hasattr with such a
>> safe version or is that considered very bad style?
>
> Dunno, I don't think we monkey-patch python internals already, do we?

We do a little, in util.py we have:

  try:
      buffer
  except NameError:
      __builtin__.buffer = fakebuffer

which is for Python 3 compatibility.

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://aragost.com/mercurial/


More information about the Mercurial-devel mailing list