Fokko commented on code in PR #6532:
URL: https://github.com/apache/iceberg/pull/6532#discussion_r1063341197
##########
python/pyiceberg/avro/decoder.py:
##########
@@ -50,10 +50,10 @@ def read(self, n: int) -> bytes:
raise ValueError(f"Requested {n} bytes to read, expected positive
integer.")
read_bytes = self._input_stream.read(n)
read_len = len(read_bytes)
- if read_len <= 0:
- raise EOFError
+ if read_len < 0:
+ raise EOFError(f"Got negative length: {read_len}")
elif read_len != n:
- raise ValueError(f"Read {len(read_bytes)} bytes, expected {n}
bytes")
+ raise EOFError(f"Read {read_len} bytes, expected {n} bytes")
Review Comment:
I had to change this to an EOF error. Since that's the error that we catch
after finish reading a block:
```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Users/fokkodriesprong/Desktop/iceberg/python/pyiceberg/manifest.py", line
139, in read_manifest_entry
for record in reader:
File
"/Users/fokkodriesprong/Desktop/iceberg/python/pyiceberg/avro/file.py", line
189, in __next__
new_block = self._read_block()
File
"/Users/fokkodriesprong/Desktop/iceberg/python/pyiceberg/avro/file.py", line
172, in _read_block
block_records = self.decoder.read_int()
File
"/Users/fokkodriesprong/Desktop/iceberg/python/pyiceberg/avro/decoder.py", line
71, in read_int
b = ord(self.read(1))
File
"/Users/fokkodriesprong/Desktop/iceberg/python/pyiceberg/avro/decoder.py", line
56, in read
raise ValueError(f"Read {read_len} bytes, expected {n} bytes")
ValueError: Read 0 bytes, expected 1 bytes
```
##########
python/pyiceberg/avro/decoder.py:
##########
@@ -50,10 +50,10 @@ def read(self, n: int) -> bytes:
raise ValueError(f"Requested {n} bytes to read, expected positive
integer.")
read_bytes = self._input_stream.read(n)
read_len = len(read_bytes)
- if read_len <= 0:
- raise EOFError
+ if read_len < 0:
+ raise EOFError(f"Got negative length: {read_len}")
Review Comment:
I think this is more accurate, since zero is not negative
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]