Mercurial > public > mercurial-scm > hg
diff mercurial/error.py @ 51283:81224afd938d
lock: properly convert error to bytes
Flagged by pytype when a later changeset is applied moving typing comment to annotation.
We fix this ahead of the annotation change to make sure pytype remains happy
after the change.
We have to do fairly crazy dance for pytype to be happy. This probably comes
from the fact IOError.filename probably claims to be `str` while it is actually
`bytes` if the filename raising that `IOError` is bytes.
At the same time, `IOError.strerror` is consistently `str` and should be passed
as `str` everywhere.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 20 Dec 2023 20:13:22 +0100 |
parents | 9d3721552b6c |
children | f15cb5111a1e |
line wrap: on
line diff
--- a/mercurial/error.py Wed Dec 20 12:51:20 2023 +0100 +++ b/mercurial/error.py Wed Dec 20 20:13:22 2023 +0100 @@ -498,8 +498,7 @@ class LockError(IOError): def __init__(self, errno, strerror, filename, desc): - # TODO: figure out if this should be bytes or str - # _type: (int, str, str, bytes) -> None + # _type: (int, str, bytes, bytes) -> None IOError.__init__(self, errno, strerror, filename) self.desc = desc @@ -508,7 +507,7 @@ class LockHeld(LockError): def __init__(self, errno, filename, desc, locker): - LockError.__init__(self, errno, b'Lock held', filename, desc) + LockError.__init__(self, errno, 'Lock held', filename, desc) self.locker = locker