Fix issue #6701. Use shutil.move instead of os.rename.