[issue2021] Turn NamedTemporaryFile into a context manager
Nick Coghlan
report at bugs.python.org
Mon Feb 11 13:56:58 CET 2008
Nick Coghlan added the comment:
Backported to 2.5 in r60728
P.S. To elaborate a bit more on why converting NamedTemporaryFile to
subclass file would be a much bigger deal than it is to just fix its
__enter__ and __exit__ methods:
- converts from old-style to new-style class
- imposes the constraints of a C base class on any subclasses
- file attribute is currently part of the public API
- need to retain wrapper approach in tempfile anyway for related type
SpooledTemporaryFile in 2.6 (as that may contain a real file or a string
IO object at different points in its lifecycle)
- no compelling use case for the change (the wrapper approach works,
what real advantage do we gain from subclassing file instead?)
- wrapper approach is much easier to reconcile with Python 3.0's io module
----------
status: pending -> closed
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2021>
__________________________________
More information about the Python-bugs-list
mailing list