def __exit__(self, exc_type, exc_value, traceback): if hasattr(GzipFile, '__exit__'): return GzipFile.__exit__(self, exc_type, exc_value, traceback) else: return self.close()