Issue 5950: Make zipimport work with zipfile containing comments (original) (raw)

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Dima.Tisnek, ZackerySpytz, barry, brett.cannon, dsamersoff, eric.snow, georg.brandl, gregory.p.smith, grubert, ncoghlan, peter.otten, rfk, serhiy.storchaka, superluser, terry.reedy, theller, twouters
Priority: normal Keywords: patch

Created on 2009-05-06 16:49 by dsamersoff, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
testcase.zip dsamersoff,2009-05-06 16:49 Testcase zipfile with comment inside
zipimport_with_comments.patch rfk,2010-07-13 00:26
Pull Requests
URL Status Linked Edit
PR 9548 merged ZackerySpytz,2018-09-24 20:29
Messages (25)
msg87340 - (view) Author: Dmitry (dsamersoff) Date: 2009-05-06 16:49
Synopsys: zimport not able to import a module from zipfile if zipfile contains comment. Versions: This is Zip 2.32 (June 19th 2006), by Info-ZIP Python 2.5.2 or 2.6.2 Steps to reproduce: create a module, create an app that imports this module. zip the module, make sure it works. Run: echo "Some comments" | zip -z module.zip the app stop working.
msg97316 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-01-06 18:26
Yes, comments are not supported right now. Documented this in r77333, and turning this issue into a feature request for adding that support.
msg109678 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-09 04:30
Does 'zimport' refer to the 3.1 zipfile or zipimport modules or an internal function called zimport?
msg109686 - (view) Author: Dmitry (dsamersoff) Date: 2010-07-09 07:00
I'm talking about internal zimport function (see attached testcase): i.e. import sys; sys.path.insert(0,'test.zip'); import test test.testme() doesn't work if test.zip contains comment.
msg110014 - (view) Author: Ryan Kelly (rfk) Date: 2010-07-11 14:24
Attached is my attempt at a patch for this functionality, along with some simple tests. This basically mirrors what's done in zipfile.py, searching backwards through the file until it finds the end-of-central-directory marker. It tries to be memory conscious by reading in small chunks. Patch is against trunk; I've also tested it against 2.7 and it seems to work. Any chance of it being backported into 2.7? Also wanted to mention a real-world usecase for this functionality. I want to digitally sign a frozen python program with appended zipfile, which involves appending the signature to the EXE. Simple to do if only zipimport would support appended comments.
msg110016 - (view) Author: Ryan Kelly (rfk) Date: 2010-07-11 14:26
Whoops, forgot to remove the line from the docs about comments not being supported. Updated the patch accordingly.
msg110059 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-12 00:17
"the line from the docs about comments not being supported." answers your question. Current behavior is documented behavior and therefor changing it is not a bugfix.
msg110151 - (view) Author: Ryan Kelly (rfk) Date: 2010-07-13 00:26
I can't imagine anyone depending on this lack-of-feature, but there's no arguing with the technicality of it. One more small incentive to make the jump to Python 3 then. Anyway, I've revisited the patch to clean up the logic and control flow, and added another test to ensure that it works even when the EOCD record crosses a chunk boundary. Also checked that it works on win32, which fortunately it did without modification.
msg110157 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-13 04:53
>I can't imagine anyone depending on this lack-of-feature, Neither can I, but I can imaging someone writing code that depended on the feature. If added to 3.1.3, then code that depended on it would not run on 3.1, 3.1.1, and 3.1.2. The same is true, of course, for bug fixes, but the doc does not need changing for bug fixes, and the impact is otherwise less. > One more small incentive to make the jump to Python 3 then. Or to 3.2 from any 3.1 version, which is the normal progession absent the dual track anomaly.
msg113452 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-09 18:54
I believe this is covered by the PEP3003 3.2 change moratorium.
msg113467 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-08-09 20:33
Why?
msg113484 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-09 21:59
Because it adds a feature to the import statement, rather than to a module, or so Dmitry said. But fine with me if it goes in now.
msg113486 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-09 22:02
On #1644818, Brett said import statement is exempt from moratorium.
msg139187 - (view) Author: engelbert gruber (grubert) * Date: 2011-06-26 15:11
+1*4
msg139192 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-06-26 17:19
Brett, Nick, this could be considered a patch to the import machinery as the bugs shows with a import statement. In any case, no one is signed up for zipimport specifically.
msg175127 - (view) Author: Dima Tisnek (Dima.Tisnek) * Date: 2012-11-07 22:13
also applies to 2.7 series over a year passed since last comment, any progress on this? I just ran into this issue myself. zipfile module handles commented zip's fine, but zipimport doesn't. I didn't expect a gotcha like this from Python!
msg175169 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-11-08 14:46
This is a feature request so it won't change in Python 2.7. As for progress, the answer is no as the hope is to eventually replace zipimport with something in pure Python thanks to importlib.
msg219263 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2014-05-28 11:26
> As for progress, the answer is no as the hope is to eventually replace > zipimport with something in pure Python thanks to importlib. Does this mean there is no chance to put this into 3.4 and 3.3, do we really have to wait until 3.5 with it's pure-python zipimport? I (together with the py2exe-users) have the same usecase as Ryan Kelly in : > I want to digitally sign a frozen python program with appended zipfile, > which involves appending the signature to the EXE. Simple to do if > only zipimport would support appended comments.
msg219266 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-05-28 13:25
I actually stopped development of a pure Python zip importer so it won't be in Python 3.5 either (http://bugs.python.org/issue17630). The motivation simply wasn't there if zipimport is going to be sticking around for bootstrapping reasons. This can still get fixed in 3.5 (3.4 is Larry's call). I have added Thomas Wouters and Greg Smith who have done the most work with zipimport to the nosy list to see if they have interest in taking a look at the patch.
msg226234 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-09-01 16:36
See for yet one use case ("git archive" creates ZIP file with archive comment).
msg325717 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-19 07:18
zipimport have been rewritten in pure Python ().
msg325721 - (view) Author: Dima Tisnek (Dima.Tisnek) * Date: 2018-09-19 07:23
Very glad to hear! Let's document what Python version(s) are "fixed". Perhaps this issue deserves a test case in .
msg325733 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-19 08:00
It is not fixed yet. But it is now easier to fix.
msg326284 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2018-09-24 20:30
I've created a PR.
msg326398 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2018-09-25 19:15
New changeset 5a5ce064b3baadcb79605c5a42ee3d0aee57cdfc by Barry Warsaw (Zackery Spytz) in branch 'master': bpo-5950: Support reading zips with comments in zipimport (#9548) https://github.com/python/cpython/commit/5a5ce064b3baadcb79605c5a42ee3d0aee57cdfc
History
Date User Action Args
2022-04-11 14:56:48 admin set github: 50200
2019-05-14 09:49:41 SilentGhost link issue36914 superseder
2018-09-25 19:16:49 barry set status: open -> closedresolution: fixedcomponents: + Library (Lib), - Interpreter Corestage: patch review -> resolved
2018-09-25 19:15:51 barry set nosy: + barrymessages: +
2018-09-24 20:30:41 ZackerySpytz set nosy: + ZackerySpytzmessages: + versions: + Python 3.8, - Python 3.6
2018-09-24 20:29:52 ZackerySpytz set pull_requests: + <pull%5Frequest8951>
2018-09-19 08:00:47 serhiy.storchaka set messages: +
2018-09-19 07:23:41 Dima.Tisnek set messages: +
2018-09-19 07🔞32 serhiy.storchaka set messages: +
2016-05-19 05:53:05 serhiy.storchaka link issue27055 superseder
2015-08-05 15:53:32 eric.snow set nosy: + superluserversions: + Python 3.6, - Python 3.4
2014-09-01 16:36:16 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2014-09-01 16:26:14 r.david.murray link issue22322 superseder
2014-05-28 13:53:50 peter.otten set nosy: + peter.otten
2014-05-28 13:25:40 brett.cannon set nosy: + twouters, gregory.p.smithmessages: +
2014-05-28 11:27:01 theller set nosy: + thellermessages: +
2012-11-13 02:53:40 eric.snow set nosy: + eric.snow
2012-11-08 14:46:22 brett.cannon set messages: + versions: + Python 3.4, - Python 2.7, Python 3.3
2012-11-07 22:13:10 Dima.Tisnek set nosy: + Dima.Tisnekmessages: + versions: + Python 2.7
2011-06-26 17:19:39 terry.reedy set nosy: + brett.cannon, ncoghlanmessages: + versions: + Python 3.3, - Python 3.2
2011-06-26 15:11:51 grubert set nosy: + grubertmessages: +
2010-08-09 22:02:33 terry.reedy set messages: +
2010-08-09 21:59:48 terry.reedy set messages: + stage: patch review
2010-08-09 20:33:27 georg.brandl set messages: + versions: + Python 3.2, - Python 3.3
2010-08-09 18:54:07 terry.reedy set messages: + versions: + Python 3.3, - Python 3.2
2010-07-13 04:53:21 terry.reedy set messages: +
2010-07-13 00:28:24 rfk set files: - zipimport_with_comments.patch
2010-07-13 00:26:13 rfk set files: + zipimport_with_comments.patchmessages: +
2010-07-12 00:17:01 terry.reedy set messages: +
2010-07-11 15:37:03 georg.brandl set title: Make zimport work with zipfile containing comments -> Make zipimport work with zipfile containing comments
2010-07-11 14:26:26 rfk set files: - zipimport_with_comments.patch
2010-07-11 14:26:14 rfk set files: + zipimport_with_comments.patchmessages: +
2010-07-11 14:24:04 rfk set files: + zipimport_with_comments.patchkeywords: + patchmessages: +
2010-07-11 13:31:57 rfk set nosy: + rfk
2010-07-09 07:00:31 dsamersoff set messages: +
2010-07-09 04:30:26 terry.reedy set nosy: + terry.reedytitle: zimport doesn't work with zipfile containing comments -> Make zimport work with zipfile containing commentsmessages: + versions: + Python 3.2, - Python 2.6, Python 2.5
2010-01-06 18:26:34 georg.brandl set type: enhancementmessages: + nosy: + georg.brandl
2009-05-06 16:49:46 dsamersoff create