python / python/cpython

OSError: [Errno 22] Invalid argument when serving files with last modified time before 1969-12-31 12:00 UTC on windows

Abierto
#101,035 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

stdlib type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
36k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Bug report

http.server.SimpleHTTPRequestHandler.send_head() does not check if a file's mtime is valid for gmtime() on windows.
An OSError: [Errno 22] Invalid argument exception will be raised which is normal according to the documentation.

https://github.com/python/cpython/blob/ef633e5000222a3dba74473c49d6a81fca0a44ec/Lib/http/server.py#L752
https://github.com/python/cpython/blob/ef633e5000222a3dba74473c49d6a81fca0a44ec/Lib/http/server.py#L766

I encounter this error when using windows built-in unzip functionality to unzip a windows WireGuard client exported zip file.
The zip file does not contain any timestamp information. And windows will not auto fill timestamp information when unzipping.
And win32 api GetFileInformationByHandle will report back a timestamp of -11635213907.559603

Your environment

  • CPython versions tested on: 3.10.9, 3.11.1, 3.12.0a4+
  • Operating system and architecture: windows 11 pro 22h2 OS build 22621.1105 amd64
Linked PRs
  • gh-101036

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza en Lib/http/server.py, en http.server.SimpleHTTPRequestHandler.send_head(), especialmente en el tratamiento de la marca de tiempo del archivo alrededor de las llamadas a gmtime() mencionadas. Reproduce el comportamiento en Windows con un archivo cuyo mtime sea anterior a 1969-12-31 y, después, revisa el PR enlazado gh-101036. Se considera terminado cuando servir un archivo así ya no genera OSError: [Errno 22].

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
web-dev
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.