This commit is contained in:
ikatyal2110 2026-08-15 13:15:38 -04:00 committed by GitHub
commit ad21d76309
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 2 deletions

View file

@ -210,13 +210,15 @@ class UpdateWrapper:
self._update = update
def __iter__(self) -> Iterator[bytes]:
encoding = getattr(self._wrapped, "encoding", None) or "utf-8"
for line in self._wrapped:
self._update(len(line))
self._update(len(line.encode(encoding, errors="replace")))
yield line
def read(self, size: int = -1) -> bytes:
data = self._wrapped.read(size)
self._update(len(data))
encoding = getattr(self._wrapped, "encoding", None) or "utf-8"
self._update(len(data.encode(encoding, errors="replace")))
return data