Skip to content

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

@EvanLai88

Description

@EvanLai88

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.

fs.st_mtime, datetime.timezone.utc)

self.date_time_string(fs.st_mtime))

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions