micropython-lib/python-stdlib/tarfile
Damien George abf316c536 tarfile: Fix FileSection.skip to not rely on extended readinto args.
Commit 2ca1527321 optimized
`FileSection.skip()` for memory use.  But that introduced a dependency on
the MicroPython-extension to stream read methods for an additional argument
specifying a maximum read size.  This optimization meant that all file-like
objects passed into TarFile must support the extended 2-argument `readinto`
form.

This is problematic for at least two use cases:
1. Nested tar files, because `FileSetion` itself doesn't support 2-argument
   `readinto`.
2. Using `mpremote mount` and reading a tar file from the remote mount,
   which also doesn't support 2-argument `readinto`.

Instead of requiring all file-like objects to implement this extended form
of `readinto`, this commit changes `FileSection.skip()` so that it doesn't
use this form.

A test is added for this case which fails without the fix here.

Signed-off-by: Damien George <damien@micropython.org>
2025-12-03 14:20:15 +11:00
..
tarfile tarfile: Fix FileSection.skip to not rely on extended readinto args. 2025-12-03 14:20:15 +11:00
example-extract.py tarfile: Rename from utarfile. 2023-07-23 11:41:44 +10:00
manifest.py tarfile: Fix FileSection.skip to not rely on extended readinto args. 2025-12-03 14:20:15 +11:00
test.tar tarfile: Add basic unittest for tarfile.TarFile. 2025-12-03 14:20:15 +11:00
test_tarfile.py tarfile: Fix FileSection.skip to not rely on extended readinto args. 2025-12-03 14:20:15 +11:00