Mercurial > hg
diff mercurial/utils/resourceutil.py @ 50928: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 | 847f703a4d13 |
children | 32a1c9226dd9 c5d6a66092e8 |
line wrap: on
line diff
--- a/mercurial/utils/resourceutil.py Thu Dec 08 15:33:19 2022 +0100 +++ b/mercurial/utils/resourceutil.py Thu Aug 31 23:56:15 2023 +0200 @@ -22,8 +22,8 @@ (portable, not much used). """ return ( - pycompat.safehasattr(sys, "frozen") # new py2exe - or pycompat.safehasattr(sys, "importers") # old py2exe + hasattr(sys, "frozen") # new py2exe + or hasattr(sys, "importers") # old py2exe or _imp.is_frozen("__main__") # tools/freeze ) @@ -59,7 +59,7 @@ from importlib import resources # pytype: disable=import-error # Force loading of the resources module - if pycompat.safehasattr(resources, 'files'): + if hasattr(resources, 'files'): resources.files # pytype: disable=module-attr else: resources.open_binary # pytype: disable=module-attr @@ -95,7 +95,7 @@ from .. import encoding def open_resource(package, name): - if pycompat.safehasattr(resources, 'files'): + if hasattr(resources, 'files'): return ( resources.files( # pytype: disable=module-attr pycompat.sysstr(package)