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.

classification
Title: Zipfile cannot be used in "with" Statement
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.1
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: alex, ezio.melotti, t.steinruecken
Priority: normal Keywords:

Created on 2010-11-03 21:28 by t.steinruecken, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg120346 - (view) Author: (t.steinruecken) Date: 2010-11-03 21:28
Using a ZipFile as a "with"-context dosnt work
(Im using the standard Ubuntu version of Python3.1)

Python 3.1.2 (r312:79147, Apr 15 2010, 15:35:48) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from zipfile import ZipFile
>>> with ZipFile("test.zip","w") as z:
...     z.close()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'ZipFile' object has no attribute '__exit__'
>>>
msg120348 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2010-11-03 21:40
Context manager support was added in 3.2
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54510
2010-11-03 22:40:26ezio.melottisetnosy: + ezio.melotti

stage: resolved
2010-11-03 21:42:28benjamin.petersonsetstatus: open -> closed
resolution: out of date
2010-11-03 21:40:17alexsetnosy: + alex
messages: + msg120348
2010-11-03 21:28:56t.steinrueckencreate