python / python/cpython

`.pyc` file in zipapp can be marked as stale if opened in a different timezone than the one it was created in

Aberta
#141,431 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

stdlib topic-importlib type-bug
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

Bug report

Bug description:

_get_mtime_and_size_of_source uses localtime rather than UTC --- in a zipapp, if the pyc was created in a timezone that is different than the timezone of the computer that it is being run on, it can be marked as 'stale', even though it shouldn't be --- for example, if the source file was last modified at 3:30 EST, that 3:30 EST will be stored in the pyc file as a Unix timestamp. However, if the zipapp is then transferred to a computer running PST, the modification time of the source file will be read from the zip file as 3:30 PST in unix time (through time.mktime), which will obviously be different than the 3:30 EST read from the pyc file directly (since it is never passed through time.mktime).

This seems to be because zip files do not store timezones with mtime, so Python is forced to interpret it as local time.

CPython versions tested on:

3.11, 3.13

Operating systems tested on:

Linux, macOS

Linked PRs
  • gh-143868
  • gh-143953

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 em _get_mtime_and_size_of_source e acompanhe como os mtime da fonte do zipapp são convertidos com time.mktime em comparação com os timestamps de pyc. Reproduza a diferença de fuso horário descrita para Python 3.11 ou 3.13 no Linux ou macOS e, em seguida, verifique se um pyc transferido entre fusos horários não é mais marcado incorretamente como obsoleto.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
backend
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

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