This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eelis
Recipients
Date 2005-01-31.05:18:41
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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.
History
Date User Action Args
2008-01-20 09:57:26adminlinkissue1112955 messages
2008-01-20 09:57:26admincreate