title: File exists error - Python tarfile
body: <p>I got a funny problem with the tarfile package on Ubuntu environment. I have the jdk package (jdk-7u5-linux-x64.tar.gz) and another package (blah.tar.gz) in the /tmp/ folder. Both are ok (which means I can extract them by right click on them). with the blah.tar.gz package, i use the flowing code: </p>
  
  <pre><code>import tarfile 
  tar = tarfile.open('/tmp/blah.tar.gz', 'r:gz') 
  tar.extractall()
  tar.close() 
  </code></pre>
  
  <p>It works well. However, when I tried with the jdk package ( tar = tarfile.open('/tmp/jdk-7u5-linux-x64.tar.gz', 'r:gz') ). I got the following error: </p>
  
  <pre><code>In [26]: tar.extractall()
  ---------------------------------------------------------------------------
  OSError                                   Traceback (most recent call last)
  
  /home/bubuzzz/Projects/secude/java/jdk/&lt;ipython console&gt; in &lt;module&gt;()
  
  /usr/lib/python2.7/tarfile.pyc in extractall(self, path, members)
     2044                 tarinfo = copy.copy(tarinfo)
     2045                 tarinfo.mode = 0700
  -&gt; 2046             self.extract(tarinfo, path)
     2047 
     2048         # Reverse sort directories.
  
  
  /usr/lib/python2.7/tarfile.pyc in extract(self, member, path)
     2081 
     2082         try:
  -&gt; 2083             self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
     2084         except EnvironmentError, e:
     2085             if self.errorlevel &gt; 0:
  
  /usr/lib/python2.7/tarfile.pyc in _extract_member(self, tarinfo, targetpath)
     2165             self.makedev(tarinfo, targetpath)
     2166         elif tarinfo.islnk() or tarinfo.issym():
  -&gt; 2167             self.makelink(tarinfo, targetpath)
     2168         elif tarinfo.type not in SUPPORTED_TYPES:
     2169             self.makeunknown(tarinfo, targetpath)
  
  /usr/lib/python2.7/tarfile.pyc in makelink(self, tarinfo, targetpath)
     2240             # For systems that support symbolic and hard links.
  
     2241             if tarinfo.issym():
  -&gt; 2242                 os.symlink(tarinfo.linkname, targetpath)
     2243             else:
     2244                 # See extract().
  
  
  OSError: [Errno 17] File exists
  </code></pre>
  
  <p>I still dont know what is wrong here. Coz when i move the jdk package to another folder, and use that code, it works well again. Before running the code, the "tmp" folder was empty. Anyone know how to solve this issue? </p>