[Python-Dev] Add a -z interpreter flag to execute a zip file

Phillip J. Eby pje at telecommunity.com
Mon Jul 23 20:02:08 CEST 2007


At 10:34 AM 7/23/2007 -0700, Guido van Rossum wrote:
>There's an ambiguity -- a Zip file could start with a Python (or
>shell, or Perl) script that bootstraps execution. This is used
>regularly. Changing the semantics just because the file *ends* with
>something funny sounds like asking for trouble.

Actually, it isn't, because you can't start a zipfile with a Python 
script.  Lord knows I've *tried*, but the Python interpreter just 
won't accept arbitrary binary data as part of a script.  :)

Second, unless you somehow managed to overcome that little obstacle, 
you're not going to be trying to run the zipfile with the Python 
interpreter, anyway.  Instead, the #! line (or .exe header on 
Windows) will be invoking whatever interpreter or program actually 
works for that file.

Third, if you mistakenly pass an existing such zipfile to a new 
Python interpreter that supports zipfiles, and there's no 
__main__.py* file in it, you're just going to get a different error 
message than the syntax error you'd have received from an older 
Python.interpreter to run it with -- but otherwise no difference.

In other words, AFAICT there's really no ambiguity here.



More information about the Python-Dev mailing list