You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
_OsPathBackend.copy() raises PermissionError instead of IsADirectoryError on Windows for a directory source #818
Its sibling _FileSystemSpecBackend.copy() does, at backend.py:563-567:
ifself.isdir(path) andnotis_dir_dst:
raiseIsADirectoryError(f'Cannot copy to {dst}. Path {path} is a directory')
On POSIX the missing check does not matter, because open() on a directory raises IsADirectoryError natively and shutil.copyfile propagates it. On Windows, opening a directory is "Access is denied":
So caller code written against the contract the fsspec backend states, and against the behaviour the os backend shows on Linux, does not catch the Windows exception. PermissionError and IsADirectoryError are siblings under OSError, neither inherits from the other, so an except IsADirectoryError clause silently misses it and the error surfaces somewhere unrelated.
test_backend[_test_copy] and test_backend[_test_copy_with_overwrite] already assert the intended type and report this. Neither has run on Windows, because the module fails collection there on import grp.
I have no Linux or macOS machine, so the POSIX half above is read from the documented open() behaviour rather than measured.
I'd like to work on this. Straightforward fix: add the same isdir check _FileSystemSpecBackend.copy() already has, so _OsPathBackend.copy() raises IsADirectoryError consistently on all platforms instead of relying on shutil.copyfile's platform-dependent behavior. Will add a Windows-specific regression test alongside it.
Activity
itzzdev09 commentedon Sep 16, 2026
I'd like to work on this. Straightforward fix: add the same isdir check _FileSystemSpecBackend.copy() already has, so _OsPathBackend.copy() raises IsADirectoryError consistently on all platforms instead of relying on shutil.copyfile's platform-dependent behavior. Will add a Windows-specific regression test alongside it.