(original) (raw)
Index: zipfile.py
--- zipfile.py (revision 76405) +++ zipfile.py (working copy) @@ -11,10 +11,10 @@ zlib = None crc32 = binascii.crc32
-all = ["BadZipfile", "error", "ZIP_STORED", "ZIP_DEFLATED", "is_zipfile", +all = ["BadZipFile", "error", "ZIP_STORED", "ZIP_DEFLATED", "is_zipfile", "ZipInfo", "ZipFile", "PyZipFile", "LargeZipFile" ]
-class BadZipfile(Exception): +class BadZipFile(Exception): pass
@@ -24,7 +24,7 @@ and those extensions are disabled. """
-error = BadZipfile # The exception raised by this module +error = BadZipFile # The exception raised by this module
ZIP64_LIMIT = (1 << 31) - 1 ZIP_FILECOUNT_LIMIT = 1 << 16 @@ -163,7 +163,7 @@ return endrec
if diskno != 0 or disks != 1:
raise BadZipfile("zipfiles that span multiple disks are not supported")
raise BadZipFile("zipfiles that span multiple disks are not supported")
fpin.seek(offset - sizeEndCentDir64Locator - sizeEndCentDir64, 2) Assume no 'zip64 extensible data'
@@ -713,7 +713,7 @@ self._RealGetContents() # seek to start of directory and overwrite self.fp.seek(self.start_dir, 0)
except BadZipfile: # file is not a zip file, just append
except BadZipFile: # file is not a zip file, just append self.fp.seek(0, 2) else: if not self._filePassed:
@@ -726,7 +726,7 @@ is bad.""" try: self._RealGetContents()
except BadZipfile:
except BadZipFile: if not self._filePassed: self.fp.close() self.fp = None
@@ -737,7 +737,7 @@ fp = self.fp endrec = _EndRecData(fp) if not endrec:
raise BadZipfile, "File is not a zip file"
raise BadZipFile, "File is not a zip file" if self.debug > 1: print endrec size_cd = endrec[_ECD_SIZE] # bytes in central directory
@@ -762,7 +762,7 @@ while total < size_cd: centdir = fp.read(sizeCentralDir) if centdir[0:4] != stringCentralDir:
raise BadZipfile, "Bad magic number for central directory"
raise BadZipFile, "Bad magic number for central directory" centdir = struct.unpack(structCentralDir, centdir) if self.debug > 2: print centdir
@@ -825,7 +825,7 @@ f = self.open(zinfo.filename, "r") while f.read(chunk_size): # Check CRC-32 pass
except BadZipfile:
def getinfo(self, name):except BadZipFile: return zinfo.filename
@@ -873,7 +873,7 @@ # Skip the file header: fheader = zef_file.read(sizeFileHeader) if fheader[0:4] != stringFileHeader:
raise BadZipfile, "Bad magic number for file header"
raise BadZipFile, "Bad magic number for file header" fheader = struct.unpack(structFileHeader, fheader) fname = zef_file.read(fheader[_FH_FILENAME_LENGTH])
@@ -881,7 +881,7 @@ zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH])
if fname != zinfo.orig_filename:
raise BadZipfile, \
raise BadZipFile, \ 'File name in directory "%s" and header "%s" differ.' % ( zinfo.orig_filename, fname)