mercurial/worker.py
changeset 49253 4c57ce494a4e
parent 49252 4d42a5fb70bf
child 49254 520722523955
--- a/mercurial/worker.py	Sat May 21 22:24:02 2022 +0200
+++ b/mercurial/worker.py	Sat May 21 23:31:30 2022 +0200
@@ -107,16 +107,16 @@
             return self._wrapped.readall()
 
         buf = bytearray(size)
-        view = memoryview(buf)
         pos = 0
 
-        while pos < size:
-            ret = self._wrapped.readinto(view[pos:])
-            if not ret:
-                break
-            pos += ret
+        with memoryview(buf) as view:
+            while pos < size:
+                with view[pos:] as subview:
+                    ret = self._wrapped.readinto(subview)
+                if not ret:
+                    break
+                pos += ret
 
-        del view
         del buf[pos:]
         return bytes(buf)