This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Update zipimport to support importlib.invalidate_caches()
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, crwilcox, desmondcheongzx, eric.araujo, eric.smith, eric.snow, gregory.p.smith, miss-islington, ncoghlan, serhiy.storchaka, superluser
Priority: normal Keywords: easy, patch

Created on 2012-04-26 17:41 by brett.cannon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24159 merged desmondcheongzx, 2021-01-08 02:38
Messages (12)
msg159404 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-04-26 17:41
zipimport's finders that get cached in sys.path_importer_cache should probably be updated to support importlib.invalidate_caches() (else the module should get re-implemented in pure Python in importlib and then be tossed).
msg159406 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-04-26 17:48
zipimport in Python sounds good to me.
msg159948 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-05-04 17:34
I should mention I have a version from importers that is probably out-of-date: http://code.google.com/p/importers/source/browse/importers/zip.py
msg159979 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2012-05-05 06:51
Moving zipimporter to Python code is harder than it sounds: we don't want to break the ability to ship the standard library itself inside a zipfile.

If you try to move zipimporter to pure Python, you could easily end up with a *very* ugly bootstrapping problem, on par with that already encountered when hacking on importlib._bootstrap.

In fact, the path of least resistance here might actually be to implement zipimporter directly *in* importlib._bootstrap.
msg160022 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-05-05 19:06
The real problem becomes the issue of what zipfile depends on, which complicates bootstrapping. I mean things could go as far as to write a script that takes in anchor points in the stdlib and freezes all code they depend on, but that seems like potential overkill and executable bloat.

But something needs to happen as zipimporter has major shortcomings thanks to to its re-implementation of zip handling (e.g. no ZIP64 support, etc.). Plus no one ever wants to touch that code.
msg197551 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2013-09-13 05:24
Brett wrote a pure python zipimporter in http://bugs.python.org/issue17630 :)

FWIW, the zipimport.c implementation (in 2.7) causes us serious pain when we've got the stdlib in a .zip file and need to update that while there are running python processes (which have cached the central directory of that .zip file but do not also keep a fd to the zip file open or even attempt to stat the file to see if it has changed [racy but it'd still be better than the nothing that is done now]).
msg325715 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-19 07:11
zipimport have been rewritten in pure Python (issue25711).
msg361711 - (view) Author: Chris Wilcox (crwilcox) * Date: 2020-02-10 19:34
What work remains to be done for this issue?
msg362842 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2020-02-27 21:21
@crwilcox Don't know what's left. That's probably part of the work that's left. ;) This issue is so old that it's possibly out-of-date since zipimport got rewritten in pure Python.
msg362889 - (view) Author: Chris Wilcox (crwilcox) * Date: 2020-02-28 17:53
That is my thinking as well after rooting around a bit. I unfortunately am not knowledgable enough here to be 100% sure it is complete.
msg362905 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2020-02-28 18:59
It looks like it hasn't been done, else https://github.com/python/cpython/blob/master/Lib/zipimport.py would have some definition of a invalidate_caches() method. And specifically the finder lacks that method so it can be called by https://github.com/python/cpython/blob/c705fd1e89ccb8f6d414ec817b4616546147d877/Lib/importlib/_bootstrap_external.py#L1245-L1257.
msg388294 - (view) Author: miss-islington (miss-islington) Date: 2021-03-08 20:06
New changeset 3abf6f010243a91bf57cbf357dac33193f7b8407 by Desmond Cheong in branch 'master':
bpo-14678: Update zipimport to support importlib.invalidate_caches() (GH-24159)
https://github.com/python/cpython/commit/3abf6f010243a91bf57cbf357dac33193f7b8407
History
Date User Action Args
2022-04-11 14:57:29adminsetgithub: 58883
2021-03-08 20:06:46brett.cannonsetversions: + Python 3.10, - Python 3.8
2021-03-08 20:06:43brett.cannonsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-03-08 20:06:09miss-islingtonsetnosy: + miss-islington
messages: + msg388294
2021-01-08 02:38:02desmondcheongzxsetkeywords: + patch
nosy: + desmondcheongzx

pull_requests: + pull_request22987
stage: patch review
2020-02-28 18:59:49brett.cannonsetmessages: + msg362905
2020-02-28 17:53:09crwilcoxsetmessages: + msg362889
2020-02-27 21:21:07brett.cannonsetmessages: + msg362842
2020-02-10 19:34:40crwilcoxsetnosy: + crwilcox
messages: + msg361711
2020-01-29 00:50:15brett.cannonsetkeywords: + easy
2018-09-19 07:11:29serhiy.storchakasetversions: + Python 3.8, - Python 3.6
nosy: + serhiy.storchaka

messages: + msg325715

type: behavior -> enhancement
2015-08-05 15:59:43eric.snowsetnosy: + superluser

versions: + Python 3.6, - Python 3.3
2013-09-13 05:24:31gregory.p.smithsetnosy: + gregory.p.smith
messages: + msg197551
2012-05-05 19:19:42eric.snowsetnosy: + eric.snow
2012-05-05 19:06:49brett.cannonsetmessages: + msg160022
2012-05-05 06:51:01ncoghlansetnosy: + ncoghlan
messages: + msg159979
2012-05-04 17:34:36brett.cannonsetmessages: + msg159948
2012-04-26 18:02:33eric.smithsetnosy: + eric.smith
2012-04-26 17:48:47eric.araujosetnosy: + eric.araujo
messages: + msg159406
2012-04-26 17:41:49brett.cannoncreate