python / python/cpython

`zipfile` and `tarfile` docs should cover local timezone impact on entry timestamps

Aberta
#123,059 1 comentário 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

docs triaged
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):

  • tarfile uses 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 extracted
  • zipfile explicitly interprets the filesystem timestamps with time.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

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. 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

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.