mercurial/profiling.py
changeset 51897 499b19683c1b
parent 51863 f4733654f144
--- a/mercurial/profiling.py	Mon Jul 08 22:46:04 2024 +0200
+++ b/mercurial/profiling.py	Thu Sep 26 02:58:50 2024 +0200
@@ -71,11 +71,14 @@
         # what is going on.
         other_tool_name = sys.monitoring.get_tool(sys.monitoring.PROFILER_ID)
         if other_tool_name == "cProfile":
-            msg = 'cannot recursively call `lsprof`'
+            msg = b'cannot recursively call `lsprof`'
             raise error.Abort(msg) from None
         else:
-            m = 'failed to start "lsprofile"; another profiler already running: %s'
-            raise error.Abort(_(m) % other_tool_name) from None
+            tool = b'<unknown>'
+            if other_tool_name:
+                tool = encoding.strtolocal(other_tool_name)
+            m = b'failed to start "lsprofile"; another profiler already running: %s'
+            raise error.Abort(_(m) % tool) from None
     try:
         yield
     finally: