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 emilyemorehouse
Recipients craigh, emilyemorehouse
Date 2018-01-28.19:13:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Thanks for the bug report!

shutil.move should certainly accept a path object, as shutil.copy does, though it should be noted that in your example, 'path' could become out of date as it does not refresh the path information. For example, with shutil.move fixed:

    >>> import os, pathlib, shutil
    >>> os.mkdir('test1')
    >>> os.mkdir('test2')
    >>> path = pathlib.Path('test1')
    >>> path.absolute()
    >>> shutil.move(path, 'test2')
    >>> path.absolute()

test1 is now actually at '/Users/e/Development/OSS/cpython/test2/test1'

For the fix:
I did a bit of digging and the error comes from a helper method _basename that uses rstrip to remove a trailing separator, hence the error as rstrip doesn't exist for a path object (and I don't think it makes sense that it should, though that was one solution). Removing the trailing separator is, however, very important in determining the full destination path.

After trying a few different approaches, I think the simplest way is to cast the src to a string before finding its appropriate basename. I also added some comments to make it more clear why _basename is used over os.path.basename to hopefully save someone else time in the future.

A more robust option would be to explicitly handle Path objects or to handle exceptions for any dst that cannot be cast to a string. However, the current patch fixes the issue without introducing new problems.
Date User Action Args
2018-01-28 19:13:57emilyemorehousesetrecipients: + emilyemorehouse, craigh
2018-01-28 19:13:57emilyemorehousesetmessageid: <>
2018-01-28 19:13:57emilyemorehouselinkissue32689 messages
2018-01-28 19:13:57emilyemorehousecreate