Mercurial > public > mercurial-scm > hg-stable
diff mercurial/pure/parsers.py @ 51799:d748fd2647f8
pure: stringify builtin exception messages
Builtin exceptions usually want strings, and display with a wierd b'' prefix if
given bytes.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 25 Jul 2024 14:40:38 -0400 |
parents | 278af66e6595 |
children | f4733654f144 |
line wrap: on
line diff
--- a/mercurial/pure/parsers.py Mon Jul 29 12:10:08 2024 -0400 +++ b/mercurial/pure/parsers.py Thu Jul 25 14:40:38 2024 -0400 @@ -25,6 +25,7 @@ from .. import ( error, + pycompat, revlogutils, util, ) @@ -235,7 +236,7 @@ parentfiledata=(mode, size, (mtime, 0, False)), ) else: - raise RuntimeError(b'unknown state: %s' % state) + raise RuntimeError('unknown state: %s' % pycompat.sysstr(state)) def set_possibly_dirty(self): """Mark a file as "possibly dirty" @@ -651,7 +652,7 @@ def _check_index(self, i): if not isinstance(i, int): - raise TypeError(b"expecting int indexes") + raise TypeError("expecting int indexes") if i < 0 or i >= len(self): raise IndexError(i) @@ -711,7 +712,7 @@ def __delitem__(self, i): if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: - raise ValueError(b"deleting slices only supports a:-1 with step 1") + raise ValueError("deleting slices only supports a:-1 with step 1") i = i.start self._check_index(i) self._stripnodes(i) @@ -790,12 +791,12 @@ count += 1 off += self.entry_size + s if off != len(self._data): - raise ValueError(b"corrupted data") + raise ValueError("corrupted data") return count def __delitem__(self, i): if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: - raise ValueError(b"deleting slices only supports a:-1 with step 1") + raise ValueError("deleting slices only supports a:-1 with step 1") i = i.start self._check_index(i) self._stripnodes(i) @@ -848,7 +849,7 @@ raise KeyError self._check_index(rev) if rev < self._lgt: - msg = b"cannot rewrite entries outside of this transaction" + msg = "cannot rewrite entries outside of this transaction" raise KeyError(msg) else: entry = list(self[rev])