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 peppergrower
Recipients peppergrower
Date 2008-10-04.11:06:07
SpamBayes Score 0.00029394188
Marked as misclassified No
Message-id <1223118393.0.0.542108397821.issue4039@psf.upfronthosting.co.za>
In-reply-to
Content
Currently, StringIO objects do not have __enter__ and __exit__ methods
associated with them.  As a result, the 'with' statement won't work
properly on StringIO objects in a construction like the following,
though they can otherwise be manipulated like files:

with obj.open_file(...) as f:
    ... 

(I brought up this behavior first on comp.lang.python,* and the above
example was borrowed from Hrvoje Niksic.)  To allow StringIO objects to
be used more interchangeably with actual file objects, could __enter__
and __exit__ methods be added?

Thanks,
peppergrower

*
http://groups.google.com/group/comp.lang.python/browse_thread/thread/6bdf65bce431e404/a5dc64f43147f4dd?lnk=gst
History
Date User Action Args
2008-10-04 11:06:33peppergrowersetrecipients: + peppergrower
2008-10-04 11:06:33peppergrowersetmessageid: <1223118393.0.0.542108397821.issue4039@psf.upfronthosting.co.za>
2008-10-04 11:06:09peppergrowerlinkissue4039 messages
2008-10-04 11:06:08peppergrowercreate