Skip to content

fs.copy.copy_file: Breaking changes between Python 3.7 and Python 3.8 #496

Open

Description

@avivace

On Python 3.7.1 with fs==2.4.12, this doesn't work:

import fs
my_fs = fs.open_fs("/")
fs.copy.copy_file(
   src_fs=my_fs,
   dst_fs=my_fs,
   src_path="/tmp/1.txt",
   dst_path="/tmp/42"
)

raising IsADirectoryError: [Errno 21] Is a directory: '/tmp/42'.

However, the same snippet succeds in Python 3.8.0 with the same version of fs. It appears that while running on Python 3.7.x the dst path must have the file name, while on 3.8.0 it can be a directory. Is this expected?

Activity

  1. althonos commented on Oct 6, 2021

    @althonos
    Member

    Thanks for the report! That's definitely not expected, as we try to get a consistent behaviour on all platforms.

    Internally, OSFS.copy uses shutil.copy2 if it is supported, which changed in Python 3.8 with added support for platform-specific copy operations. I'd think for consistency PyFilesystem2 would want to check that dst_path is not a directory.

  2. changed the title [-]fs.copy.copy_file: Breaking changes between Python 3.7 to Python 3.8[/-] [+]fs.copy.copy_file: Breaking changes between Python 3.7 and Python 3.8[/+] on Oct 11, 2021
  3. added this to the v2.4.16 milestone on Mar 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions