[issue8958] 2.7rc1 tarfile.py: `bltn_open(targetpath, "wb")` -> IOError: Is a directory

Sridhar Ratnakumar report at bugs.python.org
Mon Jun 14 19:56:46 CEST 2010


Sridhar Ratnakumar <sridharr at activestate.com> added the comment:

On 2010-06-14, at 10:43 AM, Lars Gustäbel wrote:

> Lars Gustäbel <lars at gustaebel.de> added the comment:
> 
> a) The point is: the operation simply wouldn't fail on a case-sensitive filesystem. There is no platform-specific or otherwise special code in TarFile.makefile(). It simply tries to extract the file and the filesystem layer says no, because it believes there is already a directory with the same name. The same thing happens on a Windows filesystem BTW. The problem boils down to this:
> 
>>>> os.mkdir("A")
>>>> open("a", "w")
> IOError: [Errno 21] Is a directory: 'a'
> 
> And IIUC, the Mac OS X filesystem is case-preserving(!) by default, with the possibility to create new filesystems as case-sensitive. As I said, my Mac OS X expertise is almost nonexistent, you might as well ask someone with more knowledge on Python on Mac OS X.

Ah, I see. I didn't know about this compatibility quirk.

> b) I don't know what Finder does with that archive, but I cannot think of any other way than either not to extract the file at all or to extract it under a different name or to remove the directory first and then extract the file. Could you please examine how Finder extracts this archive?

I was wrong about Finder extracting the tarball; actually I used the Finder on my macbook (10.6), where `open("a", "w")` succeeds. Whereas this issue seems to be reproducible in 10.5 or 10.4 only.

I did try to use `tar` this time, and it failed:

$ tar zxf hntool-0.1.1.tar.gz 
tar: hntool-0.1.1/hntool: Cannot open: File exists
tar: Error exit delayed from previous errors

> c) IMHO the IOError exception is perfectly fine, because this kind of issue is outside of tarfile's scope. We hit a filesystem limit here. Also, there is no decent way to work around this problem, and I think there is no need to either.

In this case, yes ... I agree.

----------

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


More information about the Python-bugs-list mailing list