@@ -692,26 +692,22 @@ def _parse_args(cls, args):
692692 return cls ._flavour .parse_parts (parts )
693693
694694 @classmethod
695- def _from_parts (cls , args , init = True ):
695+ def _from_parts (cls , args ):
696696 # We need to call _parse_args on the instance, so as to get the
697697 # right flavour.
698698 self = object .__new__ (cls )
699699 drv , root , parts = self ._parse_args (args )
700700 self ._drv = drv
701701 self ._root = root
702702 self ._parts = parts
703- if init :
704- self ._init ()
705703 return self
706704
707705 @classmethod
708- def _from_parsed_parts (cls , drv , root , parts , init = True ):
706+ def _from_parsed_parts (cls , drv , root , parts ):
709707 self = object .__new__ (cls )
710708 self ._drv = drv
711709 self ._root = root
712710 self ._parts = parts
713- if init :
714- self ._init ()
715711 return self
716712
717713 @classmethod
@@ -721,10 +717,6 @@ def _format_parsed_parts(cls, drv, root, parts):
721717 else :
722718 return cls ._flavour .join (parts )
723719
724- def _init (self ):
725- # Overridden in concrete Path
726- pass
727-
728720 def _make_child (self , args ):
729721 drv , root , parts = self ._parse_args (args )
730722 drv , root , parts = self ._flavour .join_parsed_parts (
@@ -1064,29 +1056,18 @@ class Path(PurePath):
10641056 object. You can also instantiate a PosixPath or WindowsPath directly,
10651057 but cannot instantiate a WindowsPath on a POSIX system or vice versa.
10661058 """
1067- __slots__ = (
1068- '_accessor' ,
1069- )
1059+ _accessor = _normal_accessor
1060+ __slots__ = ()
10701061
10711062 def __new__ (cls , * args , ** kwargs ):
10721063 if cls is Path :
10731064 cls = WindowsPath if os .name == 'nt' else PosixPath
1074- self = cls ._from_parts (args , init = False )
1065+ self = cls ._from_parts (args )
10751066 if not self ._flavour .is_supported :
10761067 raise NotImplementedError ("cannot instantiate %r on your system"
10771068 % (cls .__name__ ,))
1078- self ._init ()
10791069 return self
10801070
1081- def _init (self ,
1082- # Private non-constructor arguments
1083- template = None ,
1084- ):
1085- if template is not None :
1086- self ._accessor = template ._accessor
1087- else :
1088- self ._accessor = _normal_accessor
1089-
10901071 def _make_child_relpath (self , part ):
10911072 # This is an optimization used for dir walking. `part` must be
10921073 # a single part relative to this path.
@@ -1194,9 +1175,7 @@ def absolute(self):
11941175 return self
11951176 # FIXME this must defer to the specific flavour (and, under Windows,
11961177 # use nt._getfullpathname())
1197- obj = self ._from_parts ([os .getcwd ()] + self ._parts , init = False )
1198- obj ._init (template = self )
1199- return obj
1178+ return self ._from_parts ([os .getcwd ()] + self ._parts )
12001179
12011180 def resolve (self , strict = False ):
12021181 """
@@ -1212,9 +1191,7 @@ def resolve(self, strict=False):
12121191 s = str (self .absolute ())
12131192 # Now we have no symlinks in the path, it's safe to normalize it.
12141193 normed = self ._flavour .pathmod .normpath (s )
1215- obj = self ._from_parts ((normed ,), init = False )
1216- obj ._init (template = self )
1217- return obj
1194+ return self ._from_parts ((normed ,))
12181195
12191196 def stat (self ):
12201197 """
@@ -1282,9 +1259,7 @@ def readlink(self):
12821259 Return the path to which the symbolic link points.
12831260 """
12841261 path = self ._accessor .readlink (self )
1285- obj = self ._from_parts ((path ,), init = False )
1286- obj ._init (template = self )
1287- return obj
1262+ return self ._from_parts ((path ,))
12881263
12891264 def touch (self , mode = 0o666 , exist_ok = True ):
12901265 """
0 commit comments