diff mercurial/statprof.py @ 52408:9b43246e710e

statprof: stop using the `pycompat.open()` shim Different import style -> different grep pattern. Some of these lines are getting flagged as writing bytes to a non-binary file, but `pycompat.open()` doesn't stuff a `'b'` into the mode like the vfs layer does, so this is an existing bug.
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 04 Dec 2024 22:02:36 -0500
parents f4733654f144
children ef83646d5f7d
line wrap: on
line diff
--- a/mercurial/statprof.py	Wed Dec 04 21:15:30 2024 -0500
+++ b/mercurial/statprof.py	Wed Dec 04 22:02:36 2024 -0500
@@ -118,7 +118,6 @@
     List,
 )
 
-from .pycompat import open
 from . import (
     encoding,
     pycompat,
@@ -245,7 +244,7 @@
         if self.source is None:
             try:
                 lineno = self.lineno - 1  # lineno can be None
-                with open(self.path, b'rb') as fp:
+                with open(self.path, 'rb') as fp:
                     for i, line in enumerate(fp):
                         if i == lineno:
                             self.source = line.strip()
@@ -385,7 +384,7 @@
 
 
 def save_data(path):
-    with open(path, b'w+') as file:
+    with open(path, 'w+') as file:
         file.write(b"%f %f\n" % state.accumulated_time)
         for sample in state.samples:
             time = sample.time
@@ -398,7 +397,7 @@
 
 
 def load_data(path):
-    lines = open(path, b'rb').read().splitlines()
+    lines = open(path, 'rb').read().splitlines()
 
     state.accumulated_time = [float(value) for value in lines[0].split()]
     state.samples = []
@@ -831,7 +830,7 @@
 
     fd, path = pycompat.mkstemp()
 
-    with open(path, b"w+") as file:
+    with open(path, "w+") as file:
         for line, count in lines.items():
             file.write(b"%s %d\n" % (line, count))