[ python-Bugs-1112955 ] move_file()'s return value when dry_run=1
unclear
SourceForge.net
noreply at sourceforge.net
Mon Jan 31 06:18:41 CET 2005
Bugs item #1112955, was opened at 2005-01-31 06:18
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1112955&group_id=5470
Category: Distutils
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Eelis (eelis)
Assigned to: Nobody/Anonymous (nobody)
Summary: move_file()'s return value when dry_run=1 unclear
Initial Comment:
distutils.file_util.move_file has the following signature:
move_file(src, dst, verbose=0, dry_run=0)
Unfortunately, the purpose of the dry_run parameter is
not described in the documentation. However, it's
obvious that one effect of specifying dry_run=1 should
be that the file is not actually moved. Less obvious is
how dry_run=1 affects move_file's return value, which
the documentation describes as follows:
"Returns the new full name of the file."
Should the dry_run parameter be allowed to affect the
return value? My guess is that it shouldn't, but it
does (on win32 and linux):
# given a file named foo and a directory named bar
move_file('foo', 'bar', 0, 1) #-> 'bar'
move_file('foo', 'bar', 0, 0) #-> 'bar/foo'
A quick look at the source code showed that:
if isdir(dst):
dst = os.path.join(dst, basename(src))
is executed _before_:
if dry_run:
return dst
which causes the discrepancy.
Is this a bug, or should the return value of move_file
when dry_run=1 be considered unreliable? If the latter
is the case, perhaps it should be documented explicitly.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1112955&group_id=5470
More information about the Python-bugs-list
mailing list