@@ -312,7 +312,7 @@ def __init__(self, *args):
312312 f"not { type (path ).__name__ !r} " )
313313 self ._raw_path = path
314314
315- def with_segments (self , * pathsegments ):
315+ def with_path (self , * pathsegments ):
316316 """Construct a new path object from any number of path-like objects.
317317 Subclasses may override this method to customize how new path objects
318318 are created from methods like `iterdir()`.
@@ -342,7 +342,7 @@ def _load_parts(self):
342342
343343 def _from_parsed_parts (self , drv , root , tail ):
344344 path_str = self ._format_parsed_parts (drv , root , tail )
345- path = self .with_segments (path_str )
345+ path = self .with_path (path_str )
346346 path ._str = path_str or '.'
347347 path ._drv = drv
348348 path ._root = root
@@ -581,7 +581,7 @@ def relative_to(self, other, /, *_deprecated, walk_up=False):
581581 "scheduled for removal in Python {remove}" )
582582 warnings ._deprecated ("pathlib.PurePath.relative_to(*args)" , msg ,
583583 remove = (3 , 14 ))
584- other = self .with_segments (other , * _deprecated )
584+ other = self .with_path (other , * _deprecated )
585585 for step , path in enumerate ([other ] + list (other .parents )):
586586 if self .is_relative_to (path ):
587587 break
@@ -590,7 +590,7 @@ def relative_to(self, other, /, *_deprecated, walk_up=False):
590590 if step and not walk_up :
591591 raise ValueError (f"{ str (self )!r} is not in the subpath of { str (other )!r} " )
592592 parts = ['..' ] * step + self ._tail [len (path ._tail ):]
593- return self .with_segments (* parts )
593+ return self .with_path (* parts )
594594
595595 def is_relative_to (self , other , / , * _deprecated ):
596596 """Return True if the path is relative to another path or False.
@@ -601,7 +601,7 @@ def is_relative_to(self, other, /, *_deprecated):
601601 "scheduled for removal in Python {remove}" )
602602 warnings ._deprecated ("pathlib.PurePath.is_relative_to(*args)" ,
603603 msg , remove = (3 , 14 ))
604- other = self .with_segments (other , * _deprecated )
604+ other = self .with_path (other , * _deprecated )
605605 return other == self or other in self .parents
606606
607607 @property
@@ -619,7 +619,7 @@ def joinpath(self, *pathsegments):
619619 paths) or a totally different path (if one of the arguments is
620620 anchored).
621621 """
622- return self .with_segments (self ._raw_path , * pathsegments )
622+ return self .with_path (self ._raw_path , * pathsegments )
623623
624624 def __truediv__ (self , key ):
625625 try :
@@ -629,7 +629,7 @@ def __truediv__(self, key):
629629
630630 def __rtruediv__ (self , key ):
631631 try :
632- return self .with_segments (key , self ._raw_path )
632+ return self .with_path (key , self ._raw_path )
633633 except TypeError :
634634 return NotImplemented
635635
@@ -678,7 +678,7 @@ def match(self, path_pattern):
678678 """
679679 Return True if this path matches the given pattern.
680680 """
681- pat = self .with_segments (path_pattern )
681+ pat = self .with_path (path_pattern )
682682 if not pat .parts :
683683 raise ValueError ("empty pattern" )
684684 pat_parts = pat ._parts_normcase
@@ -753,7 +753,7 @@ def _make_child_relpath(self, name):
753753 path_str = f'{ path_str } { name } '
754754 else :
755755 path_str = name
756- path = self .with_segments (path_str )
756+ path = self .with_path (path_str )
757757 path ._str = path_str
758758 path ._drv = self .drive
759759 path ._root = self .root
@@ -803,7 +803,7 @@ def samefile(self, other_path):
803803 try :
804804 other_st = other_path .stat ()
805805 except AttributeError :
806- other_st = self .with_segments (other_path ).stat ()
806+ other_st = self .with_path (other_path ).stat ()
807807 return self ._flavour .samestat (st , other_st )
808808
809809 def iterdir (self ):
@@ -865,7 +865,7 @@ def absolute(self):
865865 cwd = self ._flavour .abspath (self .drive )
866866 else :
867867 cwd = os .getcwd ()
868- return self .with_segments (cwd , self ._raw_path )
868+ return self .with_path (cwd , self ._raw_path )
869869
870870 def resolve (self , strict = False ):
871871 """
@@ -883,7 +883,7 @@ def check_eloop(e):
883883 except OSError as e :
884884 check_eloop (e )
885885 raise
886- p = self .with_segments (s )
886+ p = self .with_path (s )
887887
888888 # In non-strict mode, realpath() doesn't raise on symlink loops.
889889 # Ensure we get an exception by calling stat()
@@ -973,7 +973,7 @@ def readlink(self):
973973 """
974974 if not hasattr (os , "readlink" ):
975975 raise NotImplementedError ("os.readlink() not available on this system" )
976- return self .with_segments (os .readlink (self ))
976+ return self .with_path (os .readlink (self ))
977977
978978 def touch (self , mode = 0o666 , exist_ok = True ):
979979 """
@@ -1062,7 +1062,7 @@ def rename(self, target):
10621062 Returns the new Path instance pointing to the target path.
10631063 """
10641064 os .rename (self , target )
1065- return self .with_segments (target )
1065+ return self .with_path (target )
10661066
10671067 def replace (self , target ):
10681068 """
@@ -1075,7 +1075,7 @@ def replace(self, target):
10751075 Returns the new Path instance pointing to the target path.
10761076 """
10771077 os .replace (self , target )
1078- return self .with_segments (target )
1078+ return self .with_path (target )
10791079
10801080 def symlink_to (self , target , target_is_directory = False ):
10811081 """
0 commit comments