@@ -293,9 +293,9 @@ class PurePath(object):
293
293
"""
294
294
295
295
__slots__ = (
296
- # The `_raw_path ` slot stores an unnormalized string path . This is set
296
+ # The `_raw_paths ` slot stores unnormalized string paths . This is set
297
297
# in the `__init__()` method.
298
- '_raw_path ' ,
298
+ '_raw_paths ' ,
299
299
300
300
# The `_drv`, `_root` and `_tail_cached` slots store parsed and
301
301
# normalized parts of the path. They are set when any of the `drive`,
@@ -352,10 +352,11 @@ def __init__(self, *args):
352
352
paths = []
353
353
for arg in args :
354
354
if isinstance (arg , PurePath ):
355
- path = arg ._raw_path
356
355
if arg ._flavour is ntpath and self ._flavour is posixpath :
357
356
# GH-103631: Convert separators for backwards compatibility.
358
- path = path .replace ('\\ ' , '/' )
357
+ paths .extend (path .replace ('\\ ' , '/' ) for path in arg ._raw_paths )
358
+ else :
359
+ paths .extend (arg ._raw_paths )
359
360
else :
360
361
try :
361
362
path = os .fspath (arg )
@@ -366,13 +367,8 @@ def __init__(self, *args):
366
367
"argument should be a str or an os.PathLike "
367
368
"object where __fspath__ returns a str, "
368
369
f"not { type (path ).__name__ !r} " )
369
- paths .append (path )
370
- if len (paths ) == 0 :
371
- self ._raw_path = ''
372
- elif len (paths ) == 1 :
373
- self ._raw_path = paths [0 ]
374
- else :
375
- self ._raw_path = self ._flavour .join (* paths )
370
+ paths .append (path )
371
+ self ._raw_paths = paths
376
372
377
373
def with_segments (self , * pathsegments ):
378
374
"""Construct a new path object from any number of path-like objects.
@@ -402,7 +398,14 @@ def _parse_path(cls, path):
402
398
return drv , root , parsed
403
399
404
400
def _load_parts (self ):
405
- drv , root , tail = self ._parse_path (self ._raw_path )
401
+ paths = self ._raw_paths
402
+ if len (paths ) == 0 :
403
+ path = ''
404
+ elif len (paths ) == 1 :
405
+ path = paths [0 ]
406
+ else :
407
+ path = self ._flavour .join (* paths )
408
+ drv , root , tail = self ._parse_path (path )
406
409
self ._drv = drv
407
410
self ._root = root
408
411
self ._tail_cached = tail
@@ -733,10 +736,17 @@ def parents(self):
733
736
def is_absolute (self ):
734
737
"""True if the path is absolute (has both a root and, if applicable,
735
738
a drive)."""
736
- # ntpath.isabs() is defective - see GH-44626 .
737
739
if self ._flavour is ntpath :
740
+ # ntpath.isabs() is defective - see GH-44626.
738
741
return bool (self .drive and self .root )
739
- return self ._flavour .isabs (self ._raw_path )
742
+ elif self ._flavour is posixpath :
743
+ # Optimization: work with raw paths on POSIX.
744
+ for path in self ._raw_paths :
745
+ if path .startswith ('/' ):
746
+ return True
747
+ return False
748
+ else :
749
+ return self ._flavour .isabs (str (self ))
740
750
741
751
def is_reserved (self ):
742
752
"""Return True if the path contains one of the special names reserved
0 commit comments