Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ZipFile tests fail in negative timezone offsets on reproducible build environments #134261

Open
Labels
testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error
@ctrlaltf2

Description

@ctrlaltf2

Bug report

Bug description:

Background

Bug

If building on a reproducible environment such as NixOS, and your local timezone has a negative UTC offset, a large number of the ZipFile tests fail due to a underflow of the DOS date value:

  • Zips by default store file timestamps as a DOS date and a DOS time, They are unsigned and 16-bits wide.
  • NixOS sets environment variableSOURCE_DATE_EPOCH to315532800 (1980-01-01 00:00:00 UTC) to specifically support programs and standards assuming DOS time (stdenv: set SOURCE_DATE_EPOCH to a value python supports NixOS/nixpkgs#89794), of which zip is one.
  • In recent ZipFile updates,SOURCE_DATE_EPOCH is read from if it exists. If it exists, it's not taken as UTC and is instead converted to the system's local time:
    • # gh-91279: Set the SOURCE_DATE_EPOCH to a specific timestamp
      epoch=os.environ.get('SOURCE_DATE_EPOCH')
      get_time=int(epoch)ifepochelsetime.time()
      self.date_time=time.localtime(get_time)[:6]
  • If your local time has a negative UTC offset, this ends up subtracting from the minimum possible DOS date value, which underflows to what would be a negative DOS date.
  • In tests,ValueError is raised anytime a file is written to a ZipFile, because the DOS date under reproducible systems is not in the range0 <= date <= 65535.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp