mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-115961: Add name and mode attributes for compressed file-like objects (GH-116036)
* Add name and mode attributes for compressed and archived file-like objects in modules bz2, lzma, tarfile and zipfile. * Change the value of the mode attribute of GzipFile from integer (1 or 2) to string ('rb' or 'wb'). * Change the value of the mode attribute of ZipExtFile from 'r' to 'rb'.
This commit is contained in:
parent
ccda738284
commit
51ef89cd9a
17 changed files with 246 additions and 37 deletions
|
@ -587,6 +587,8 @@ class TestGzip(BaseTest):
|
|||
self.assertRaises(AttributeError, f.fileno)
|
||||
|
||||
def test_fileobj_mode(self):
|
||||
self.assertEqual(gzip.READ, 'rb')
|
||||
self.assertEqual(gzip.WRITE, 'wb')
|
||||
gzip.GzipFile(self.filename, "wb").close()
|
||||
with open(self.filename, "r+b") as f:
|
||||
with gzip.GzipFile(fileobj=f, mode='r') as g:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue