transforms: fix copy-paste issue in Sized

This commit is contained in:
Shiz 2021-06-26 05:30:40 +02:00
parent 4c00689442
commit 6924c94a13
1 changed files with 4 additions and 4 deletions

View File

@ -52,7 +52,7 @@ class SizedStream:
if n > remaining:
raise EOFError
self._pos += n
return self._file.write(data, bits=bits)
return self._stream.write(data, bits=bits)
def seek(self, offset: Pos, whence: int) -> None:
if whence == os.SEEK_SET:
@ -64,7 +64,7 @@ class SizedStream:
if pos < self._start:
raise OSError(errno.EINVAL, os.strerror(errno.EINVAL), offset)
self._pos = pos - self._start
return self._file.seek(pos, os.SEEK_SET)
return self._stream.seek(pos, os.SEEK_SET)
def tell(self) -> Pos:
return self._start + self._pos
@ -81,14 +81,14 @@ class Sized(G[T], Wrapper[T]):
limit = max(0, context.get(self.limit))
start = stream.tell()
value = super().parse(context, SizedStream(stream, limit))
stream.seek(start + limit)
stream.seek(start + limit, os.SEEK_SET)
return value
def dump(self, context: Context, stream: Stream, value: O[T]) -> None:
limit = max(0, context.get(self.limit))
start = stream.tell()
super().dump(context, SizedStream(stream, limit), value)
stream.seek(start + limit)
stream.seek(start + limit, os.SEEK_SET)
def sizeof(self, context: Context, value: O[T]) -> O[Pos]:
return context.peek(self.limit)