Mercurial > hg
diff contrib/perf.py @ 42063:912d82daeda3
perf: make perf.run-limits code work with Python 3
We need b'' because perf.py isn't run through the source
transformer.
We need to cast the exception to bytes using pycompat.bytestr()
because ValueError can't be %s formatted due to built-in exceptions
lacking __bytes__.
We need to pycompat.sysstr() before the float() and int() cast
so the ValueError message doesn't have b'' in it.
Even with that, it looks like the error message for the ValueError
for float casts added quotes, so we need to account for that in test
output.
Differential Revision: https://phab.mercurial-scm.org/D6200
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 04 Apr 2019 17:47:25 -0700 |
parents | 4c700c847aa2 |
children | caebe5e7f4bd |
line wrap: on
line diff
--- a/contrib/perf.py Mon Dec 25 05:55:50 2017 -0800 +++ b/contrib/perf.py Thu Apr 04 17:47:25 2019 -0700 @@ -316,22 +316,22 @@ limitspec = ui.configlist(b"perf", b"run-limits", []) limits = [] for item in limitspec: - parts = item.split('-', 1) + parts = item.split(b'-', 1) if len(parts) < 2: - ui.warn(('malformatted run limit entry, missing "-": %s\n' + ui.warn((b'malformatted run limit entry, missing "-": %s\n' % item)) continue try: - time_limit = float(parts[0]) + time_limit = float(pycompat.sysstr(parts[0])) except ValueError as e: - ui.warn(('malformatted run limit entry, %s: %s\n' - % (e, item))) + ui.warn((b'malformatted run limit entry, %s: %s\n' + % (pycompat.bytestr(e), item))) continue try: - run_limit = int(parts[1]) + run_limit = int(pycompat.sysstr(parts[1])) except ValueError as e: - ui.warn(('malformatted run limit entry, %s: %s\n' - % (e, item))) + ui.warn((b'malformatted run limit entry, %s: %s\n' + % (pycompat.bytestr(e), item))) continue limits.append((time_limit, run_limit)) if not limits: