Skip to content

Conversation

@dpgeorge
Copy link
Member

@dpgeorge dpgeorge commented Dec 2, 2025

Commit 2ca1527 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.

Tests TarFile iteration and extracting file information.

Signed-off-by: Damien George <damien@micropython.org>
Commit 2ca1527 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>
@dpgeorge
Copy link
Member Author

dpgeorge commented Dec 2, 2025

Alternative to #1032.

@projectgus projectgus merged commit abf316c into micropython:master Dec 3, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants