diff --git a/contrib/perf.py b/contrib/perf.py
index 8de1b5a009eecca5c7a7401ee40750128fd84f4e_Y29udHJpYi9wZXJmLnB5..912d82daeda335c719757c29a10c5dd6edc9dd4e_Y29udHJpYi9wZXJmLnB5 100644
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -316,5 +316,5 @@
     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:
@@ -320,5 +320,5 @@
         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:
@@ -322,5 +322,5 @@
                      % item))
             continue
         try:
-            time_limit = float(parts[0])
+            time_limit = float(pycompat.sysstr(parts[0]))
         except ValueError as e:
@@ -326,5 +326,5 @@
         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:
@@ -329,4 +329,4 @@
             continue
         try:
-            run_limit = int(parts[1])
+            run_limit = int(pycompat.sysstr(parts[1]))
         except ValueError as e:
@@ -332,6 +332,6 @@
         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:
diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t
index 8de1b5a009eecca5c7a7401ee40750128fd84f4e_dGVzdHMvdGVzdC1jb250cmliLXBlcmYudA==..912d82daeda335c719757c29a10c5dd6edc9dd4e_dGVzdHMvdGVzdC1jb250cmliLXBlcmYudA== 100644
--- a/tests/test-contrib-perf.t
+++ b/tests/test-contrib-perf.t
@@ -260,7 +260,8 @@
   malformatted run limit entry, missing "-": 500
   ! wall * comb * user * sys * (best of 5) (glob)
   $ hg perfparents --config perf.stub=no --config perf.run-limits='aaa-12, 0.000000001-5'
-  malformatted run limit entry, could not convert string to float: aaa: aaa-12
+  malformatted run limit entry, could not convert string to float: aaa: aaa-12 (no-py3 !)
+  malformatted run limit entry, could not convert string to float: 'aaa': aaa-12 (py3 !)
   ! wall * comb * user * sys * (best of 5) (glob)
   $ hg perfparents --config perf.stub=no --config perf.run-limits='12-aaaaaa, 0.000000001-5'
   malformatted run limit entry, invalid literal for int() with base 10: 'aaaaaa': 12-aaaaaa