statichttprepo: stop shadowing the `bytes` builtin
authorMatt Harbison <matt_harbison@yahoo.com>
Wed, 25 Sep 2024 01:16:47 -0400
changeset 51900 77a9c7d8a7ba
parent 51899 e26a08563223
child 51901 f0e07efc199f
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.
mercurial/statichttprepo.py
--- 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