Commit a99320b
authored
fix(fsspec): handle zero-byte files in
## Summary
Fix `FsspecInputFile.__len__` and `FsspecOutputFile.__len__` so
zero-byte files return `0` instead of being treated as missing metadata.
Both methods previously used truthiness checks on
`object_info.get(...)`, which caused valid sizes like `0` to fall
through to the runtime error path.
## Changes
- check for `Size` key presence explicitly
- check for `size` key presence explicitly
- add a regression test covering zero-byte lengths for both metadata key
variants
## Verification
- `python -m pytest tests/io/test_fsspec.py -k zero_length_of_file -q`__len__ (#3353)1 parent 4b3ccbb commit a99320b
2 files changed
Lines changed: 22 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
342 | 342 | | |
343 | 343 | | |
344 | 344 | | |
| |||
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
149 | 163 | | |
150 | 164 | | |
151 | 165 | | |
| |||
0 commit comments