Commit abf316c
tarfile: Fix FileSection.skip to not rely on extended readinto args.
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>1 parent 1390722 commit abf316c
File tree
3 files changed
+15
-4
lines changed- python-stdlib/tarfile
- tarfile
3 files changed
+15
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
0 commit comments