[issue5513] "What's New" should say VERY CLEARLY that the type file is gone

David W. Lambert report at bugs.python.org
Thu Mar 19 16:36:53 CET 2009


David W. Lambert <lambertdw at corning.com> added the comment:

#OOPS!  I forgot the subtlety.
#I must also retain the stream
#else it gets collected.
#Nasty.


import io

class file(io.TextIOWrapper):

    '''condensing code for this list without test is a no no!'''

    def __init__(self,name):
        self.stream = open(name)   # SAVE THE STREAM!
        super().__init__(self.stream.buffer)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5513>
_______________________________________


More information about the Python-bugs-list mailing list