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.

Author ncoghlan
Recipients gregory.p.smith, loewis, manis, ncoghlan
Date 2009-11-18.12:18:31
SpamBayes Score 9.5992e-09
Marked as misclassified No
Message-id <1258546713.22.0.0347956893009.issue6749@psf.upfronthosting.co.za>
In-reply-to
Content
A few pointers in case anyone decides to follow this up further:

Zipfile execution is just a special case of normal zipimport: the
zipfile's name is placed at the head of sys.path and a (very) rough
equivalent of "import __main__" is then invoked.

So for zipfile execution to support password protected zipfiles, general
zipimport would need to support them as well.

However, this runs into the problem that invocation of the zipimport
module is largely implicit - the import engine invokes sys.path_hooks
entries (which includes ZipImporter automatically) for a given sys.path
entry and finds that, sure enough, ZipImporter recognises it and creates
an appropriate object to handle it.

So the trick lies in getting the password to the importer that needs to
know it in order to open the zipfile.

For the general case, you could create a new path hook that had a list
of filename pattern<->password pairs that could be placed in
sys.path_hooks ahead of the normal zipimport hook. If it saw a pattern
it recognised, it could use the appropriate password to open the zipfile
and return a corresponding importer object (you could do this largely
independently of the standard library itself - PEP 302 is expressly
designed to let third party developers run with this kind of idea).

That wouldn't help much with zipfile execution though, as you still
wouldn't have a mechanism for providing the password on the command line.
History
Date User Action Args
2009-11-18 12:18:33ncoghlansetrecipients: + ncoghlan, loewis, gregory.p.smith, manis
2009-11-18 12:18:33ncoghlansetmessageid: <1258546713.22.0.0347956893009.issue6749@psf.upfronthosting.co.za>
2009-11-18 12:18:32ncoghlanlinkissue6749 messages
2009-11-18 12:18:31ncoghlancreate