diff -r -u rev56308/Doc/lib/libzipfile.tex new/Doc/lib/libzipfile.tex --- rev56308/Doc/lib/libzipfile.tex Wed Aug 15 23:08:03 2007 +++ new/Doc/lib/libzipfile.tex Wed Aug 15 23:20:43 2007 @@ -144,7 +144,8 @@ \begin{methoddesc}{open}{name\optional{, mode\optional{, pwd}}} Extract a member from the archive as a file-like object (ZipExtFile). - \var{name} is the name of the file in the archive. The \var{mode} + \var{name} is the name of the file in the archive, or a ZipInfo object. + The \var{mode} parameter, if included, must be one of the following: \code{'r'} (the default), \code{'U'}, or \code{'rU'}. Choosing \code{'U'} or \code{'rU'} will enable universal newline support in the read-only @@ -182,7 +183,8 @@ \end{methoddesc} \begin{methoddesc}{read}{name\optional{, pwd}} - Return the bytes of the file in the archive. The archive must be + Return the bytes of the file or ZipInfo object \var{name} in the archive. + The archive must be open for read or append. \var{pwd} is the password used for encrypted files and, if specified, it will override the default password set with \method{setpassword()}. Calling \method{read()} on a closed ZipFile diff -r -u rev56308/Lib/zipfile.py new/Lib/zipfile.py --- rev56308/Lib/zipfile.py Wed Aug 15 22:31:52 2007 +++ new/Lib/zipfile.py Wed Aug 15 23:05:33 2007 @@ -754,9 +754,15 @@ else: zef_file = open(self.filename, 'rb') - # Get info object for name - zinfo = self.getinfo(name) + # Get info object + if isinstance(name, ZipInfo): + # 'name' is the info object + zinfo = name + else: + # Get info object for name + zinfo = self.getinfo(name) + # XXX Why is `filepos` computed next? It's never referenced. filepos = zef_file.tell() zef_file.seek(zinfo.header_offset, 0)