equal
deleted
inserted
replaced
105 def read(self, size=-1): |
105 def read(self, size=-1): |
106 if size < 0: |
106 if size < 0: |
107 return self._wrapped.readall() |
107 return self._wrapped.readall() |
108 |
108 |
109 buf = bytearray(size) |
109 buf = bytearray(size) |
110 view = memoryview(buf) |
|
111 pos = 0 |
110 pos = 0 |
112 |
111 |
113 while pos < size: |
112 with memoryview(buf) as view: |
114 ret = self._wrapped.readinto(view[pos:]) |
113 while pos < size: |
115 if not ret: |
114 with view[pos:] as subview: |
116 break |
115 ret = self._wrapped.readinto(subview) |
117 pos += ret |
116 if not ret: |
118 |
117 break |
119 del view |
118 pos += ret |
|
119 |
120 del buf[pos:] |
120 del buf[pos:] |
121 return bytes(buf) |
121 return bytes(buf) |
122 |
122 |
123 |
123 |
124 if pycompat.isposix or pycompat.iswindows: |
124 if pycompat.isposix or pycompat.iswindows: |