Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 50587:7b0cc86c5d74
safehasattr: pass attribute name as string instead of bytes
This is a step toward replacing `util.safehasattr` usage with plain `hasattr`.
The builtin function behave poorly in Python2 but this was fixed in Python3.
These change are done one by one as they tend to have a small odd to trigger
puzzling breackage.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 02 Feb 2023 17:20:46 +0100 |
parents | 4fafc6642bee |
children | 489268c8ee7e |
comparison
equal
deleted
inserted
replaced
50586:b0e3f1508a25 | 50587:7b0cc86c5d74 |
---|---|
1448 # Not all storage may be revlogs. If requested, try to return an actual | 1448 # Not all storage may be revlogs. If requested, try to return an actual |
1449 # revlog instance. | 1449 # revlog instance. |
1450 if returnrevlog: | 1450 if returnrevlog: |
1451 if isinstance(r, revlog.revlog): | 1451 if isinstance(r, revlog.revlog): |
1452 pass | 1452 pass |
1453 elif util.safehasattr(r, b'_revlog'): | 1453 elif util.safehasattr(r, '_revlog'): |
1454 r = r._revlog # pytype: disable=attribute-error | 1454 r = r._revlog # pytype: disable=attribute-error |
1455 elif r is not None: | 1455 elif r is not None: |
1456 raise error.InputError( | 1456 raise error.InputError( |
1457 _(b'%r does not appear to be a revlog') % r | 1457 _(b'%r does not appear to be a revlog') % r |
1458 ) | 1458 ) |