changeset 51900:77a9c7d8a7ba

statichttprepo: stop shadowing the `bytes` builtin PyCharm flagged it, but I also misunderstood when looking at the code, because the name implied a byte string, not a number.
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 25 Sep 2024 01:16:47 -0400
parents e26a08563223
children f0e07efc199f
files mercurial/statichttprepo.py
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/statichttprepo.py	Wed Sep 25 01:12:39 2024 -0400
+++ b/mercurial/statichttprepo.py	Wed Sep 25 01:16:47 2024 -0400
@@ -52,14 +52,14 @@
     def seek(self, pos):
         self.pos = pos
 
-    def read(self, bytes: int = -1):
+    def read(self, n: int = -1):
         req = urlreq.request(pycompat.strurl(self.url))
         end = ''
 
-        if bytes == 0:
+        if n == 0:
             return b''
-        elif bytes > 0:
-            end = "%d" % (self.pos + bytes - 1)
+        elif n > 0:
+            end = "%d" % (self.pos + n - 1)
         if self.pos or end:
             req.add_header('Range', 'bytes=%d-%s' % (self.pos, end))
 
@@ -79,14 +79,14 @@
         if code == 200:
             # HTTPRangeHandler does nothing if remote does not support
             # Range headers and returns the full entity. Let's slice it.
-            if bytes > 0 and (self.pos + bytes) < len(data):
-                data = data[self.pos : self.pos + bytes]
+            if n > 0 and (self.pos + n) < len(data):
+                data = data[self.pos : self.pos + n]
             elif self.pos < len(data):
                 data = data[self.pos :]
             else:
                 data = b''
-        elif 0 < bytes < len(data):
-            data = data[:bytes]
+        elif 0 < n < len(data):
+            data = data[:n]
         self.pos += len(data)
         return data