#6511: ZipFile will now raise BadZipfile when opening an empty or tiny file,
like it does for larger invalid files.
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 6ee9923..2aa4bff 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -198,7 +198,10 @@
# Check to see if this is ZIP file with no archive comment (the
# "end of central directory" structure should be the last item in the
# file if this is the case).
- fpin.seek(-sizeEndCentDir, 2)
+ try:
+ fpin.seek(-sizeEndCentDir, 2)
+ except IOError:
+ return None
data = fpin.read()
if data[0:4] == stringEndArchive and data[-2:] == "\000\000":
# the signature is correct and there's no comment, unpack structure