import sys
import tarfile
import contextlib

def _tarfile_open_ex(*args, **kwargs):
	"""
	Extend result as a context manager.
	"""
	return contextlib.closing(tarfile.open(*args, **kwargs))

tarfile_open = _tarfile_open_ex if sys.version_info < (2,7) else tarfile.open

import sys
import tarfile
import contextlib

def _tarfile_open_ex(*args, **kwargs):
	"""
	Extend result as a context manager.
	"""
	return contextlib.closing(tarfile.open(*args, **kwargs))

if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[:2] < (3, 2):
    tarfile_open = _tarfile_open_ex
else:
    tarfile_open = tarfile.open

Fix "AttributeError: 'TarFile' object has no attribute '__exit__'" with Python 3.1.
Fix "AttributeError: 'TarFile' object has no attribute '__exit__'" with Python 3.1.

  import sys
  import tarfile
  import contextlib
  
  def _tarfile_open_ex(*args, **kwargs):
  	"""
  	Extend result as a context manager.
  	"""
  	return contextlib.closing(tarfile.open(*args, **kwargs))
  
- tarfile_open = _tarfile_open_ex if sys.version_info < (2,7) else tarfile.open
+ if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[:2] < (3, 2):
+     tarfile_open = _tarfile_open_ex
+ else:
+     tarfile_open = tarfile.open
  
Fix "AttributeError: 'TarFile' object has no attribute '__exit__'" with Python 3.1.
## Code Before:
import sys
import tarfile
import contextlib

def _tarfile_open_ex(*args, **kwargs):
	"""
	Extend result as a context manager.
	"""
	return contextlib.closing(tarfile.open(*args, **kwargs))

tarfile_open = _tarfile_open_ex if sys.version_info < (2,7) else tarfile.open

## Instruction:
Fix "AttributeError: 'TarFile' object has no attribute '__exit__'" with Python 3.1.
## Code After:
import sys
import tarfile
import contextlib

def _tarfile_open_ex(*args, **kwargs):
	"""
	Extend result as a context manager.
	"""
	return contextlib.closing(tarfile.open(*args, **kwargs))

if sys.version_info[:2] < (2, 7) or (3, 0) <= sys.version_info[:2] < (3, 2):
    tarfile_open = _tarfile_open_ex
else:
    tarfile_open = tarfile.open
