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

Aperta
#141,431 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

stdlib topic-importlib type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da _get_mtime_and_size_of_source e segui come gli mtime del sorgente di zipapp vengono convertiti con time.mktime rispetto ai timestamp dei pyc. Riproduci la differenza di fuso orario descritta per Python 3.11 o 3.13 su Linux o macOS, quindi verifica che un pyc trasferito tra fusi orari non venga più contrassegnato erroneamente come obsoleto.

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
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.