[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-03-21 Thread Raghuram Devarakonda
Changes by Raghuram Devarakonda <[EMAIL PROTECTED]>: -- resolution: accepted -> fixed status: open -> closed __ Tracker <[EMAIL PROTECTED]> __ _

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-03-18 Thread Sean Reifschneider
Sean Reifschneider <[EMAIL PROTECTED]> added the comment: After reviewing the discussion I'm going to accept this because: Guido seemed to me to say "figure it out among yourselves". We're talking about shutil, so mimicing the shell move (mv) semantics is not entirely unreasonable. The current

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: By the way, if we really wanted to be complete in the unit tests, we should also test the case where either src or dst is a symlink to a directory. But it's still much better than originally - there was hardly any unit test for shutil.move(). ___

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-29 Thread Raghuram Devarakonda
Raghuram Devarakonda added the comment: We are back to square 1 :-). Your patch incorporates Facundo's suggestion which is 'rename(src_file, dst_dir/`basename src_file`). It is not clear to me from rereading the earlier comments whether Guido rejected this approach or not. I would personally pref

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: Hi Raghuram, I'm confused, because I can't reproduce it either. I'm afraid I had drunk too much or too little coffee when typing that. Perhaps the patch's semantics should be reconsidered then... What do you think? __ Tracker <[E

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-28 Thread Raghuram Devarakonda
Raghuram Devarakonda added the comment: Hi Antoine, You stated the following in a previous comment: "Right now, shutil.move(src_dir, dst_dir) replaces dst_dir with src_dir if dst_dir is empty, but moves src_dir inside dst_dir otherwise." But my test shows differently. If dst_dir doesn't exist

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-24 Thread Antoine Pitrou
Antoine Pitrou added the comment: Here is a patch, which also contains additional unit tests for shutil.move(). It would be nice if people tested it under various configurations, to see if there are any problems. Added file: http://bugs.python.org/file9281/shutilmove.patch _

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-23 Thread Guido van Rossum
Guido van Rossum added the comment: > Before tackling this, I'd like a precision on os.rename(src, dst) > semantics. The documentation says "If dst is a directory, OSError will > be raised". However, under Linux, if src is a directory and dst is an > empty directory, dst is overwritten with src:

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-23 Thread Raghuram Devarakonda
Raghuram Devarakonda added the comment: > Does this mean we should preserve this behaviour for shutil.move() as well? I don't think so. The key is to remember that shutil.move() is os.rename() with some additional benefits (as stated by Guido in an earlier comment). Also, changing the behaviour

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: Does this mean we should preserve this behaviour for shutil.move() as well? Right now, shutil.move(src_dir, dst_dir) replaces dst_dir with src_dir if dst_dir is empty, but moves src_dir inside dst_dir otherwise. __ Tracker <[EMAIL

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-23 Thread Raghuram Devarakonda
Raghuram Devarakonda added the comment: > Before tackling this, I'd like a precision on os.rename(src, dst) > semantics. The documentation says "If dst is a directory, OSError will > be raised". However, under Linux, if src is a directory and dst is an > empty directory, dst is overwritten with s

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: Before tackling this, I'd like a precision on os.rename(src, dst) semantics. The documentation says "If dst is a directory, OSError will be raised". However, under Linux, if src is a directory and dst is an empty directory, dst is overwritten with src: $ mkdir s

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-22 Thread Guido van Rossum
Guido van Rossum added the comment: Antoine: please just ignore me, even though I may once have written this code, I clearly don't understand it any more. :-) All we need now is a patch and someone to review it, right? __ Tracker <[EMAIL PROTECTED]>

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-22 Thread Antoine Pitrou
Antoine Pitrou added the comment: Raghuram, I had understood that, I was answering Guido's objection :-) __ Tracker <[EMAIL PROTECTED]> __ ___ Python-bug

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-22 Thread Raghuram Devarakonda
Raghuram Devarakonda added the comment: `shutil.move(source_file, destination_dir)` does move source_file to destination_dir but the point is that even when source and destinations are on the same file system, it still "copies" the data when there is no need for it. The reason is explained in the

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-22 Thread Antoine Pitrou
Antoine Pitrou added the comment: I don't see where there is a change in semantics. Today, `shutil.move(source_file, destination_dir)` already moves source_file inside the destination_dir (it doesn't replace the latter with the former). Is there a misunderstanding? -- nosy: +pitrou versi

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-21 Thread Raghuram Devarakonda
Changes by Raghuram Devarakonda: -- components: +Documentation -Library (Lib) __ Tracker <[EMAIL PROTECTED]> __ ___ Python-bugs-list mailing lis

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-12 Thread Ingemar Nilsson
Ingemar Nilsson added the comment: > If you want a way to do the "mv" semantics, propose > a new API. shutil.mv()? __ Tracker <[EMAIL PROTECTED]> __ ___

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-12 Thread Raghuram Devarakonda
Raghuram Devarakonda added the comment: Then, a small change in the doc might clarify the usage (as OP suggested); "If the destination is on our current filesystem, then simply use rename." can be replaced with: "If the destination is a fiile and is on same filesystem as that of src, then simp

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-11 Thread Guido van Rossum
Guido van Rossum added the comment: > Since we already have os.rename, wouldn't it be better for shutil.move() > to be closer to command line 'mv'? I think Facundo's approach should work. I'd rather not do this. It might cause disasters for code that expects the old semantics. If you want a way

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-11 Thread Raghuram Devarakonda
Raghuram Devarakonda added the comment: Since we already have os.rename, wouldn't it be better for shutil.move() to be closer to command line 'mv'? I think Facundo's approach should work. -- nosy: +draghuram __ Tracker <[EMAIL PROTECTED]>

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-10 Thread Ingemar Nilsson
Ingemar Nilsson added the comment: Well, if that's what you want, I suggest documenting it in the manual. >From reading the manual, I thought that shutil.move() would behave like mv, and I was surprised that it doesn't. To me the big issue isn't how it is solved, it's rather that its behavior is

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-10 Thread Guido van Rossum
Guido van Rossum added the comment: We should first decide what should happen. While for command line tools "mv FILE DIR" is established syntax for "mv FILE DIR/`basename FILE`", I'm not at all sure that shutil.move(src, dst) should do the same. I think it should be closer to the UNIX os.rename

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-10 Thread Facundo Batista
Facundo Batista added the comment: I have another way: * Check if the destination is a directory, and in such case make an os.path.join(destination, originfile), and then use os.rename() with this new destination. What do you think? Do you think this way suffers from any multiplatform issue? M

[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-09 Thread Ingemar Nilsson
New submission from Ingemar Nilsson: If you use shutil.move(src, dst) to move a file src to a directory dst, the file will not be renamed into the dst directory, but rather copied-then-removed, even if src and dst is on the same filesystem. There are several ways to fix this: * (The easiest) Fix