`zipfile` and `tarfile` docs should cover local timezone impact on entry timestamps
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
In a project that aims to emit reproducible archives, tar.xz archives were working as expected, but zip archives were ending up with timestamp discrepancies between local builds in AEST (UTC+10) and CI builds in UTC.
I eventually tracked this down to differing timestamp handling conventions in tarfile and zipfile (these conventions aren't unique to Python, so we can't readily eliminate the discrepancy, we can only document it):
tarfileuses the timestamps as they are, so if the filesystem stores timestamps in UTC (as most common filesystems other than FAT/FAT32/VFAT will do), they will be added to the file as UTC. If the filesystem stores local time, it will still be used without modification, but will probably be interpreted as UTC when the archive is extractedzipfileexplicitly interprets the filesystem timestamps withtime.localtime, so they will be added to the file as local time by default. If the filesystem already uses local time, the timezone offset will be applied a second time (potentially resulting in a stored modification time in the future for local timezones with a positive offset from UTC)
tarfile has an additional timezone related complication in that some compression formats (at least gzip) include a file creation time header: https://github.com/python/cpython/issues/75707
Discourse thread: https://discuss.python.org/t/tarfile-vs-zipfile-timezone-discrepancy-in-handling-modification-times/61016
Linked PRs
- gh-155195
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece revisando a documentação de zipfile e tarfile junto com a discussão vinculada no Discourse e o problema de timestamp do gzip. Documente como o tratamento do fuso horário local afeta os timestamps das entradas em ambos os formatos de arquivo, incluindo a complicação adicional do horário de criação do gzip; o PR vinculado gh-155195 mostra que esse trabalho já está em andamento.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- documentation
- Tipo de issue
- Documentação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 38/100