homepage

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: Make zipimport work with zipfile containing comments
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8
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 msg110014:
> 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 issue22322 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 (issue25711).
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 issue25711.
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:48adminsetgithub: 50200
2019年05月14日 09:49:41SilentGhostlinkissue36914 superseder
2018年09月25日 19:16:49barrysetstatus: open -> closed
resolution: fixed
components: + Library (Lib), - Interpreter Core
stage: patch review -> resolved
2018年09月25日 19:15:51barrysetnosy: + barry
messages: + msg326398
2018年09月24日 20:30:41ZackerySpytzsetnosy: + ZackerySpytz

messages: + msg326284
versions: + Python 3.8, - Python 3.6
2018年09月24日 20:29:52ZackerySpytzsetpull_requests: + pull_request8951
2018年09月19日 08:00:47serhiy.storchakasetmessages: + msg325733
2018年09月19日 07:23:41Dima.Tisneksetmessages: + msg325721
2018年09月19日 07:18:32serhiy.storchakasetmessages: + msg325717
2016年05月19日 05:53:05serhiy.storchakalinkissue27055 superseder
2015年08月05日 15:53:32eric.snowsetnosy: + superluser

versions: + Python 3.6, - Python 3.4
2014年09月01日 16:36:16serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg226234
2014年09月01日 16:26:14r.david.murraylinkissue22322 superseder
2014年05月28日 13:53:50peter.ottensetnosy: + peter.otten
2014年05月28日 13:25:40brett.cannonsetnosy: + twouters, gregory.p.smith
messages: + msg219266
2014年05月28日 11:27:01thellersetnosy: + theller
messages: + msg219263
2012年11月13日 02:53:40eric.snowsetnosy: + eric.snow
2012年11月08日 14:46:22brett.cannonsetmessages: + msg175169
versions: + Python 3.4, - Python 2.7, Python 3.3
2012年11月07日 22:13:10Dima.Tisneksetnosy: + Dima.Tisnek

messages: + msg175127
versions: + Python 2.7
2011年06月26日 17:19:39terry.reedysetnosy: + brett.cannon, ncoghlan

messages: + msg139192
versions: + Python 3.3, - Python 3.2
2011年06月26日 15:11:51grubertsetnosy: + grubert
messages: + msg139187
2010年08月09日 22:02:33terry.reedysetmessages: + msg113486
2010年08月09日 21:59:48terry.reedysetmessages: + msg113484
stage: patch review
2010年08月09日 20:33:27georg.brandlsetmessages: + msg113467
versions: + Python 3.2, - Python 3.3
2010年08月09日 18:54:07terry.reedysetmessages: + msg113452
versions: + Python 3.3, - Python 3.2
2010年07月13日 04:53:21terry.reedysetmessages: + msg110157
2010年07月13日 00:28:24rfksetfiles: - zipimport_with_comments.patch
2010年07月13日 00:26:13rfksetfiles: + zipimport_with_comments.patch

messages: + msg110151
2010年07月12日 00:17:01terry.reedysetmessages: + msg110059
2010年07月11日 15:37:03georg.brandlsettitle: Make zimport work with zipfile containing comments -> Make zipimport work with zipfile containing comments
2010年07月11日 14:26:26rfksetfiles: - zipimport_with_comments.patch
2010年07月11日 14:26:14rfksetfiles: + zipimport_with_comments.patch

messages: + msg110016
2010年07月11日 14:24:04rfksetfiles: + zipimport_with_comments.patch
keywords: + patch
messages: + msg110014
2010年07月11日 13:31:57rfksetnosy: + rfk
2010年07月09日 07:00:31dsamersoffsetmessages: + msg109686
2010年07月09日 04:30:26terry.reedysetnosy: + terry.reedy
title: zimport doesn't work with zipfile containing comments -> Make zimport work with zipfile containing comments
messages: + msg109678

versions: + Python 3.2, - Python 2.6, Python 2.5
2010年01月06日 18:26:34georg.brandlsettype: enhancement

messages: + msg97316
nosy: + georg.brandl
2009年05月06日 16:49:46dsamersoffcreate

AltStyle によって変換されたページ (->オリジナル) /