@@ -110,7 +110,7 @@ class PurePath(_abc.PurePathBase):
110110 # path. It's set when `__hash__()` is called for the first time.
111111 '_hash' ,
112112 )
113- pathmod = os .path
113+ parser = os .path
114114
115115 def __new__ (cls , * args , ** kwargs ):
116116 """Construct a PurePath from one or several strings and or existing
@@ -126,7 +126,7 @@ def __init__(self, *args):
126126 paths = []
127127 for arg in args :
128128 if isinstance (arg , PurePath ):
129- if arg .pathmod is ntpath and self .pathmod is posixpath :
129+ if arg .parser is ntpath and self .parser is posixpath :
130130 # GH-103631: Convert separators for backwards compatibility.
131131 paths .extend (path .replace ('\\ ' , '/' ) for path in arg ._raw_paths )
132132 else :
@@ -187,7 +187,7 @@ def _str_normcase(self):
187187 try :
188188 return self ._str_normcase_cached
189189 except AttributeError :
190- if _abc ._is_case_sensitive (self .pathmod ):
190+ if _abc ._is_case_sensitive (self .parser ):
191191 self ._str_normcase_cached = str (self )
192192 else :
193193 self ._str_normcase_cached = str (self ).lower ()
@@ -203,34 +203,34 @@ def __hash__(self):
203203 def __eq__ (self , other ):
204204 if not isinstance (other , PurePath ):
205205 return NotImplemented
206- return self ._str_normcase == other ._str_normcase and self .pathmod is other .pathmod
206+ return self ._str_normcase == other ._str_normcase and self .parser is other .parser
207207
208208 @property
209209 def _parts_normcase (self ):
210210 # Cached parts with normalized case, for comparisons.
211211 try :
212212 return self ._parts_normcase_cached
213213 except AttributeError :
214- self ._parts_normcase_cached = self ._str_normcase .split (self .pathmod .sep )
214+ self ._parts_normcase_cached = self ._str_normcase .split (self .parser .sep )
215215 return self ._parts_normcase_cached
216216
217217 def __lt__ (self , other ):
218- if not isinstance (other , PurePath ) or self .pathmod is not other .pathmod :
218+ if not isinstance (other , PurePath ) or self .parser is not other .parser :
219219 return NotImplemented
220220 return self ._parts_normcase < other ._parts_normcase
221221
222222 def __le__ (self , other ):
223- if not isinstance (other , PurePath ) or self .pathmod is not other .pathmod :
223+ if not isinstance (other , PurePath ) or self .parser is not other .parser :
224224 return NotImplemented
225225 return self ._parts_normcase <= other ._parts_normcase
226226
227227 def __gt__ (self , other ):
228- if not isinstance (other , PurePath ) or self .pathmod is not other .pathmod :
228+ if not isinstance (other , PurePath ) or self .parser is not other .parser :
229229 return NotImplemented
230230 return self ._parts_normcase > other ._parts_normcase
231231
232232 def __ge__ (self , other ):
233- if not isinstance (other , PurePath ) or self .pathmod is not other .pathmod :
233+ if not isinstance (other , PurePath ) or self .parser is not other .parser :
234234 return NotImplemented
235235 return self ._parts_normcase >= other ._parts_normcase
236236
@@ -247,10 +247,10 @@ def __str__(self):
247247 @classmethod
248248 def _format_parsed_parts (cls , drv , root , tail ):
249249 if drv or root :
250- return drv + root + cls .pathmod .sep .join (tail )
251- elif tail and cls .pathmod .splitdrive (tail [0 ])[0 ]:
250+ return drv + root + cls .parser .sep .join (tail )
251+ elif tail and cls .parser .splitdrive (tail [0 ])[0 ]:
252252 tail = ['.' ] + tail
253- return cls .pathmod .sep .join (tail )
253+ return cls .parser .sep .join (tail )
254254
255255 def _from_parsed_parts (self , drv , root , tail ):
256256 path_str = self ._format_parsed_parts (drv , root , tail )
@@ -265,11 +265,11 @@ def _from_parsed_parts(self, drv, root, tail):
265265 def _parse_path (cls , path ):
266266 if not path :
267267 return '' , '' , []
268- sep = cls .pathmod .sep
269- altsep = cls .pathmod .altsep
268+ sep = cls .parser .sep
269+ altsep = cls .parser .altsep
270270 if altsep :
271271 path = path .replace (altsep , sep )
272- drv , root , rel = cls .pathmod .splitroot (path )
272+ drv , root , rel = cls .parser .splitroot (path )
273273 if not root and drv .startswith (sep ) and not drv .endswith (sep ):
274274 drv_parts = drv .split (sep )
275275 if len (drv_parts ) == 4 and drv_parts [2 ] not in '?.' :
@@ -290,7 +290,7 @@ def _raw_path(self):
290290 elif len (paths ) == 1 :
291291 path = paths [0 ]
292292 else :
293- path = self .pathmod .join (* paths )
293+ path = self .parser .join (* paths )
294294 return path
295295
296296 @property
@@ -360,8 +360,8 @@ def name(self):
360360
361361 def with_name (self , name ):
362362 """Return a new path with the file name changed."""
363- m = self .pathmod
364- if not name or m .sep in name or (m .altsep and m .altsep in name ) or name == '.' :
363+ p = self .parser
364+ if not name or p .sep in name or (p .altsep and p .altsep in name ) or name == '.' :
365365 raise ValueError (f"Invalid name { name !r} " )
366366 tail = self ._tail .copy ()
367367 if not tail :
@@ -413,13 +413,13 @@ def is_relative_to(self, other, /, *_deprecated):
413413 def is_absolute (self ):
414414 """True if the path is absolute (has both a root and, if applicable,
415415 a drive)."""
416- if self .pathmod is posixpath :
416+ if self .parser is posixpath :
417417 # Optimization: work with raw paths on POSIX.
418418 for path in self ._raw_paths :
419419 if path .startswith ('/' ):
420420 return True
421421 return False
422- return self .pathmod .isabs (self )
422+ return self .parser .isabs (self )
423423
424424 def is_reserved (self ):
425425 """Return True if the path contains one of the special names reserved
@@ -428,8 +428,8 @@ def is_reserved(self):
428428 "for removal in Python 3.15. Use os.path.isreserved() to "
429429 "detect reserved paths on Windows." )
430430 warnings .warn (msg , DeprecationWarning , stacklevel = 2 )
431- if self .pathmod is ntpath :
432- return self .pathmod .isreserved (self )
431+ if self .parser is ntpath :
432+ return self .parser .isreserved (self )
433433 return False
434434
435435 def as_uri (self ):
@@ -462,7 +462,7 @@ def _pattern_stack(self):
462462 raise NotImplementedError ("Non-relative patterns are unsupported" )
463463 elif not parts :
464464 raise ValueError ("Unacceptable pattern: {!r}" .format (pattern ))
465- elif pattern [- 1 ] in (self .pathmod .sep , self .pathmod .altsep ):
465+ elif pattern [- 1 ] in (self .parser .sep , self .parser .altsep ):
466466 # GH-65238: pathlib doesn't preserve trailing slash. Add it back.
467467 parts .append ('' )
468468 parts .reverse ()
@@ -487,7 +487,7 @@ class PurePosixPath(PurePath):
487487 On a POSIX system, instantiating a PurePath should return this object.
488488 However, you can also instantiate it directly on any system.
489489 """
490- pathmod = posixpath
490+ parser = posixpath
491491 __slots__ = ()
492492
493493
@@ -497,7 +497,7 @@ class PureWindowsPath(PurePath):
497497 On a Windows system, instantiating a PurePath should return this object.
498498 However, you can also instantiate it directly on any system.
499499 """
500- pathmod = ntpath
500+ parser = ntpath
501501 __slots__ = ()
502502
503503
@@ -607,7 +607,7 @@ def _make_child_relpath(self, name):
607607 path_str = str (self )
608608 tail = self ._tail
609609 if tail :
610- path_str = f'{ path_str } { self .pathmod .sep } { name } '
610+ path_str = f'{ path_str } { self .parser .sep } { name } '
611611 elif path_str != '.' :
612612 path_str = f'{ path_str } { name } '
613613 else :
@@ -675,7 +675,7 @@ def absolute(self):
675675 drive , root , rel = os .path .splitroot (cwd )
676676 if not rel :
677677 return self ._from_parsed_parts (drive , root , self ._tail )
678- tail = rel .split (self .pathmod .sep )
678+ tail = rel .split (self .parser .sep )
679679 tail .extend (self ._tail )
680680 return self ._from_parsed_parts (drive , root , tail )
681681
0 commit comments