Skip to content

zipimport should not check pyc timestamps against zipped py files #67922

Closed

Description

@gpshead
BPO 23734
Nosy @brettcannon, @gpshead, @ncoghlan, @elprans, @ericsnowcurrently, @serhiy-storchaka
PRs
  • bpo-34726: Fix handling of hash-based pycs in zipimport #10327
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-11-14.00:54:49.285>
    created_at = <Date 2015-03-21.18:59:07.067>
    labels = ['extension-modules', '3.8', 'type-feature', '3.7']
    title = 'zipimport should not check pyc timestamps against zipped py files'
    updated_at = <Date 2018-11-14.00:54:49.283>
    user = 'https://github.com/gpshead'

    bugs.python.org fields:

    activity = <Date 2018-11-14.00:54:49.283>
    actor = 'gregory.p.smith'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-11-14.00:54:49.285>
    closer = 'gregory.p.smith'
    components = ['Extension Modules']
    creation = <Date 2015-03-21.18:59:07.067>
    creator = 'gregory.p.smith'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 23734
    keywords = ['patch']
    message_count = 4.0
    messages = ['238824', '325730', '329316', '329877']
    nosy_count = 7.0
    nosy_names = ['brett.cannon', 'gregory.p.smith', 'ncoghlan', 'Elvis.Pranskevichus', 'eric.snow', 'serhiy.storchaka', 'superluser']
    pr_nums = ['10327']
    priority = 'low'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23734'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    Activity

    1. gpshead commented on Mar 21, 2015

      @gpshead
      MemberAuthor

      The zipimport module checks the timestamp of a pyc file loaded from the zip file against the timestamp of a corresponding py file in the zip if any. This seems pointless. By the time someone has created a zip file for zipimport they should have guaranteed that the pyc's are fresh or not have put them into the zip file at all (wasteful).

      https://hg.python.org/cpython/file/e8878579eb68/Modules/zipimport.c#l1187

      There is a comment in the code alluding to this, but the mtime check is still done right above.

    2. added
      extension-modules
      type-feature
      on Mar 21, 2015
    3. serhiy-storchaka commented on Sep 19, 2018

      @serhiy-storchaka
      Member

      zipimport has been rewritten in pure Python (bpo-25711).

    4. elprans commented on Nov 5, 2018

      elpransmannequin
      Mannequin

      I don't think that breaking the .pyc contract by assumption is a good thing. The desired behavior of never checking the .pyc freshness can be achieved by using unchecked hash-based compilation, or using hash-based compilation and --check-hash-based-pycs=never. Perhaps we can go further and add a --check-timestamp-based-pycs=never, but IMO, this should be explicit in all cases, including zipimport.

    5. gpshead commented on Nov 14, 2018

      @gpshead
      MemberAuthor

      Correct, this issue was filed before we had the new pyc options (which came out of our September core dev. sprint in 2016 iirc).

      I'll just close it, the way forward for people using zip files on modern CPython interpreters is to explicitly use the new unchecked feature.

    6. added
      3.7 (EOL)
      3.8 (EOL)
      on Nov 14, 2018
    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)3.8 (EOL)extension-modulestype-feature

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions