PyZipFile

Emile van Sebille emile at fenx.com
Fri Jul 13 08:14:30 EDT 2001


Whoops, where'd my response go?  ;-)

You're getting the error because you're not eval'ing source code, but the
contents of a pyc file.

If what you're trying to do is execute code stored in a zipfile python
archive, this should work:

exec(marshal.loads(p.read('pe/lang.pyc')[8:]))

HTH,

--

Emile van Sebille
emile at fenx.com

---------
"Emile van Sebille" <emile at fenx.com> wrote in message
news:9imotd$jrp8f$1 at ID-11957.news.dfncis.de...
>
>
> --
>
> Emile van Sebille
> emile at fenx.com
>
> ---------
> "gods1child" <alankarmisra at hotmail.com> wrote in message
> news:25b2e0d9.0107122104.50347e10 at posting.google.com...
> > Why wont the following code work? Thanx.
> >
> > import zipfile
> > p = zipfile.PyZipFile("c:\\pe\\arc.zip","w",zipfile.ZIP_STORED)
> > p.writepy("c:\\pe")
> > p.close()
> > p = zipfile.PyZipFile("c:\\pe\\arc.zip","r",zipfile.ZIP_STORED)
> > eval(p.read("pe/lang.pyc"))
> > p.close()
> >
> > ----------------------------------------------------
> > Traceback (most recent call last):
> >   File "C:/pe/nest.py", line 6, in ?
> >     eval(p.read("pe/lang.pyc"))
> > TypeError: expected string without null bytes
>




More information about the Python-list mailing list