Re: shutil _isindir



David Hoese wrote:

I wasn't really sure where to post this since the python-dev list seems
way too official. I'm wondering/questioning the behavior of
shutil.move. It currently does a check for if the dst is inside the src
directory with a _destinsrc function. This function uses
os.path.abspath to convert the arguments, but I think it should convert
using os.path.realpath. A recent problem I had with this I ended up
asking on stackoverflow:
http://stackoverflow.com/questions/7854608/python-shutil-move-odd-
softlinking

So I was wondering if this sounds like a change that should happen in
the shutil code or should programmers(me) just be more careful. I feel
like it should be in the shutil code since its getting around a checked
case (destination inside source) and it can end up deleting information
when a move was intended. But then again this has been in the standard
lib for a while now, so I'm guessing there are reasons for it...plus it
was a dumb mistake by me.

So I guess what I'm asking is what are the reasons that _destinsrc uses
abspath instead of realpath? And is there a better place to ask this?

FYI, I was provided this link to the shutil.py source on SO:
http://hg.python.org/cpython/file/d30482d51c25/Lib/shutil.py#l262

Your suggestion makes sense to me and I don't see any disadvantages. I
encourage you to file a bug report on bugs.python.org, preferably with a
patch.

If there are any problems with the proposed change they can be discussed
there.

.