This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author __starrify__
Recipients __starrify__
Date 2016-02-03.08:48:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1454489307.52.0.490426016128.issue26272@psf.upfronthosting.co.za>
In-reply-to
Content
When passing a file object to `zipfile.ZipFile` for reading it fails in Python 3.5.1 it fails. While the same code in Python 2.7.11 works.
Also loading that specific file directly from file path works in Python 3.5.1.
(Please see the sample testing code below for details)

[pengyu@GLaDOS tmp]$ echo "test message" > testfile
[pengyu@GLaDOS tmp]$ zip testfile.zip testfile
updating: testfile (stored 0%)
[pengyu@GLaDOS tmp]$ file testfile.zip 
testfile.zip: Zip archive data, at least v1.0 to extract
[pengyu@GLaDOS tmp]$ python -c "a = open('testfile.zip'); import zipfile; b = zipfile.ZipFile(a, 'r')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.5/zipfile.py", line 1026, in __init__
    self._RealGetContents()
  File "/usr/lib/python3.5/zipfile.py", line 1093, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
[pengyu@GLaDOS tmp]$ python2 -c "a = open('testfile.zip'); import zipfile; b = zipfile.ZipFile(a, 'r')"
[pengyu@GLaDOS tmp]$ python -c "import zipfile; b = zipfile.ZipFile('testfile.zip', 'r')"
[pengyu@GLaDOS tmp]$ python --version
Python 3.5.1
[pengyu@GLaDOS tmp]$ python2 --version
Python 2.7.11
History
Date User Action Args
2016-02-03 08:48:27__starrify__setrecipients: + __starrify__
2016-02-03 08:48:27__starrify__setmessageid: <1454489307.52.0.490426016128.issue26272@psf.upfronthosting.co.za>
2016-02-03 08:48:27__starrify__linkissue26272 messages
2016-02-03 08:48:27__starrify__create