def destructor(self): assert isinstance(self, W_File) try: self.direct_close() except StreamErrors, e: operr = wrap_streamerror(self.space, e, self.w_name) raise operr
def __del__(self): # assume that the file and stream objects are only visible in the # thread that runs __del__, so no race condition should be possible self.clear_all_weakrefs() try: self.direct_close() except StreamErrors, e: operr = wrap_streamerror(self.space, e, self.w_name) operr.write_unraisable(self.space, '__del__ of ', self)
def get_file(space, w_file, filename, filemode): if w_file is None or space.is_w(w_file, space.w_None): try: return streamio.open_file_as_stream(filename, filemode) except StreamErrors, e: # XXX this is not quite the correct place, but it will do for now. # XXX see the issue which I'm sure exists already but whose number # XXX I cannot find any more... raise wrap_streamerror(space, e)
def file_fdopen(self, fd, mode="r", buffering=-1): try: self.direct_fdopen(fd, mode, buffering) except StreamErrors, e: raise wrap_streamerror(self.space, e)
def file_fdopen(self, fd, mode="r", buffering=-1): try: self.direct_fdopen(fd, mode, buffering) except StreamErrors, e: raise wrap_streamerror(self.space, e, self.w_name)