@@ -689,6 +689,8 @@ def __init__(
689
689
self ._dyn_patcher : Optional [DynamicPatcher ] = None
690
690
self ._patching = False
691
691
self ._paused = False
692
+ self .has_copy_file_range = False
693
+ self .has_copy_file = False
692
694
693
695
def checkcache (self , filename = None ):
694
696
"""Calls the original linecache.checkcache making sure no fake OS calls
@@ -990,6 +992,14 @@ def setUp(self, doctester: Any = None) -> None:
990
992
if self .has_fcopy_file :
991
993
shutil ._HAS_FCOPYFILE = False # type: ignore[attr-defined]
992
994
995
+ self .has_copy_file_range = (
996
+ sys .platform == "linux"
997
+ and hasattr (shutil , "_USE_CP_COPY_FILE_RANGE" )
998
+ and shutil ._USE_CP_COPY_FILE_RANGE
999
+ )
1000
+ if self .has_copy_file_range :
1001
+ shutil ._USE_CP_COPY_FILE_RANGE = False # type: ignore[attr-defined]
1002
+
993
1003
# do not use the fd functions, as they may not be available in the target OS
994
1004
if hasattr (shutil , "_use_fd_functions" ):
995
1005
shutil ._use_fd_functions = False # type: ignore[module-attr]
@@ -1047,7 +1057,8 @@ def _set_glob_os_functions(self):
1047
1057
if sys .version_info >= (3 , 13 ):
1048
1058
globber = glob ._StringGlobber # type: ignore[module-attr]
1049
1059
globber .lstat = staticmethod (os .lstat )
1050
- globber .scandir = staticmethod (os .scandir )
1060
+ if sys .version_info < (3 , 14 ):
1061
+ globber .scandir = staticmethod (os .scandir )
1051
1062
1052
1063
def patch_functions (self ) -> None :
1053
1064
assert self ._stubs is not None
@@ -1124,6 +1135,8 @@ def tearDown(self, doctester: Any = None):
1124
1135
self .stop_patching ()
1125
1136
if self .has_fcopy_file :
1126
1137
shutil ._HAS_FCOPYFILE = True # type: ignore[attr-defined]
1138
+ if self .has_copy_file_range :
1139
+ shutil ._USE_CP_COPY_FILE_RANGE = True # type: ignore[attr-defined]
1127
1140
1128
1141
reset_ids ()
1129
1142
if self .is_doc_test :
0 commit comments