Mercurial > hg
changeset 49802:f3f33980f19b
pycompat: explicitly prefix builtin attr usage with `builtins.`
It doesn't seem like this would fix any bug, because the wrapped functions that
take bytes instead of str are defined after these calls. But PyCharm was
flagging the second and third uses, saying "Type 'str' doesn't have expected
attribute 'decode'". It wasn't flagging the first, but I changed it for
consistency.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 14 Dec 2022 01:38:52 -0500 |
parents | 9cd327509cd4 |
children | 55d45d0de4e7 |
files | mercurial/pycompat.py |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/pycompat.py Wed Dec 14 01:32:03 2022 -0500 +++ b/mercurial/pycompat.py Wed Dec 14 01:38:52 2022 -0500 @@ -128,7 +128,7 @@ long = int -if getattr(sys, 'argv', None) is not None: +if builtins.getattr(sys, 'argv', None) is not None: # On POSIX, the char** argv array is converted to Python str using # Py_DecodeLocale(). The inverse of this is Py_EncodeLocale(), which # isn't directly callable from Python code. In practice, os.fsencode() @@ -220,7 +220,7 @@ return s if not isinstance( s, (bytes, bytearray) - ) and not hasattr( # hasattr-py3-only + ) and not builtins.hasattr( # hasattr-py3-only s, u'__bytes__' ): s = str(s).encode('ascii') @@ -297,7 +297,7 @@ def getdoc(obj): """Get docstring as bytes; may be None so gettext() won't confuse it with _('')""" - doc = getattr(obj, '__doc__', None) + doc = builtins.getattr(obj, '__doc__', None) if doc is None: return doc return sysbytes(doc)