Mercurial > hg
comparison mercurial/error.py @ 51286: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 |
comparison
equal
deleted
inserted
replaced
51285:9d3721552b6c | 51286:81224afd938d |
---|---|
496 super(UnknownVersion, self).__init__(msg, hint=hint) | 496 super(UnknownVersion, self).__init__(msg, hint=hint) |
497 | 497 |
498 | 498 |
499 class LockError(IOError): | 499 class LockError(IOError): |
500 def __init__(self, errno, strerror, filename, desc): | 500 def __init__(self, errno, strerror, filename, desc): |
501 # TODO: figure out if this should be bytes or str | 501 # _type: (int, str, bytes, bytes) -> None |
502 # _type: (int, str, str, bytes) -> None | |
503 IOError.__init__(self, errno, strerror, filename) | 502 IOError.__init__(self, errno, strerror, filename) |
504 self.desc = desc | 503 self.desc = desc |
505 | 504 |
506 # no __bytes__() because error message is derived from the standard IOError | 505 # no __bytes__() because error message is derived from the standard IOError |
507 | 506 |
508 | 507 |
509 class LockHeld(LockError): | 508 class LockHeld(LockError): |
510 def __init__(self, errno, filename, desc, locker): | 509 def __init__(self, errno, filename, desc, locker): |
511 LockError.__init__(self, errno, b'Lock held', filename, desc) | 510 LockError.__init__(self, errno, 'Lock held', filename, desc) |
512 self.locker = locker | 511 self.locker = locker |
513 | 512 |
514 | 513 |
515 class LockUnavailable(LockError): | 514 class LockUnavailable(LockError): |
516 pass | 515 pass |