mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-10-29 06:37:09 +01:00
Merge c6a84225a2 into 9c66bafa52
This commit is contained in:
commit
8b30fd1aa4
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