tarfile: addfile() doesn't set member offsets
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en tarfile.TarFile.addfile() y compara los offsets de TarInfo en memoria con los valores producidos al volver a abrir el archivo. Ejecuta el reproductor de BytesIO proporcionado y verifica que getmembers() informe de los valores esperados de offset y offset_data para ambos miembros; revisa los PRs vinculados gh-150128, gh-150131 y gh-150278 antes de comenzar.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 25/100