tarfile: addfile() doesn't set member offsets
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
It appears that tarfile.TarFile.addfile() sets neither offset nor offset_data attributes in the TarInfo added to self.members, when it's done adding the file. Members in a reopened TAR have correct values.
Reproducer
from io import BytesIO
from tarfile import TarFile, TarInfo
with TarFile("test.tar", "w") as tar:
data = b"data"
tarinfo = TarInfo("test1.txt")
tarinfo.size = len(data)
tar.addfile(tarinfo, BytesIO(data))
tarinfo = TarInfo("test2.txt")
tarinfo.size = len(data)
tar.addfile(tarinfo, BytesIO(data))
for member in tar.getmembers():
print(member.name, member.offset, member.offset_data)
with TarFile("test.tar", "r") as tar:
for member in tar.getmembers():
print(member.name, member.offset, member.offset_data)
Expected output
test1.txt 0 512
test2.txt 1024 1536
test1.txt 0 512
test2.txt 1024 1536
Actual output
test1.txt 0 0
test2.txt 0 0
test1.txt 0 512
test2.txt 1024 1536
CPython versions tested on:
3.15
Operating systems tested on:
Linux
Linked PRs
- gh-150128
- gh-150131
- gh-150278
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da tarfile.TarFile.addfile() e confronta gli offset di TarInfo in memoria con i valori prodotti quando l'archivio viene riaperto. Esegui il riproduttore BytesIO fornito e verifica che getmembers() riporti i valori attesi di offset e offset_data per entrambi i membri; esamina le PR collegate gh-150128, gh-150131 e gh-150278 prima di iniziare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 25/100