GH-73991: Support copying directory symlinks on older Windows (#120807)

Check for `ERROR_INVALID_PARAMETER` when calling `_winapi.CopyFile2()` and
raise `UnsupportedOperation`. In `Path.copy()`, handle this exception and
fall back to the `PathBase.copy()` implementation.
This commit is contained in:
Barney Gale 2024-07-03 04:30:29 +01:00 committed by GitHub
parent 089835469d
commit f09d184821
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 40 additions and 29 deletions

View file

@ -16,10 +16,7 @@ import operator
import posixpath
from glob import _GlobberBase, _no_recurse_symlinks
from stat import S_ISDIR, S_ISLNK, S_ISREG, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO
from ._os import copyfileobj
__all__ = ["UnsupportedOperation"]
from ._os import UnsupportedOperation, copyfileobj
@functools.cache
@ -27,12 +24,6 @@ def _is_case_sensitive(parser):
return parser.normcase('Aa') == 'Aa'
class UnsupportedOperation(NotImplementedError):
"""An exception that is raised when an unsupported operation is called on
a path object.
"""
pass
class ParserBase:
"""Base class for path parsers, which do low-level path manipulation.