-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make zipimport work with zipfile containing comments #50200
Comments
Synopsys: Steps to reproduce: |
Yes, comments are not supported right now. Documented this in r77333, and turning this issue into a feature request for adding that support. |
Does 'zimport' refer to the 3.1 zipfile or zipimport modules or an internal function called zimport? |
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. |
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. |
Whoops, forgot to remove the line from the docs about comments not being supported. Updated the patch accordingly. |
"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. |
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. |
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.
Or to 3.2 from any 3.1 version, which is the normal progession absent the dual track anomaly. |
I believe this is covered by the PEP-3003 3.2 change moratorium. |
Why? |
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. |
On bpo-1644818, Brett said import statement is exempt from moratorium. |
+1*4 |
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. |
also applies to 2.7 series over a year passed since last comment, any progress on this? I just ran into this issue myself. |
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. |
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 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. |
See bpo-22322 for yet one use case ("git archive" creates ZIP file with archive comment). |
zipimport have been rewritten in pure Python (bpo-25711). |
Very glad to hear! |
It is not fixed yet. But it is now easier to fix. |
I've created a PR. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: