mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-08 01:24:20 +02:00
Merge c6a84225a2 into 56dd09702f
This commit is contained in:
commit
ad21d76309
2 changed files with 37 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue