Jeffrey Kintscher <[email protected]> added the comment:
The workaround is to override _init(), which I agree is not desirable.
This is the relevant code in PurePath, which is the super class of
PurePosixPath:
@classmethod
def _from_parsed_parts(cls, drv, root, parts, init=True):
self = object.__new__(cls)
self._drv = drv
self._root = root
self._parts = parts
if init:
self._init()
return self
...
def _init(self):
# Overridden in concrete Path
pass
To me, the clean way to get the desired behavior seems like it would be to have
_init() call self.__init__().
def _init(self):
# Overridden in concrete Path
self.__init__()
This fixes p.parent, but GithubPath() ends up calling GithubPath.__init__()
twice – the first time by PurePath.__new__() calling PurePath._init() and the
second time by the GithubPath object creation.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41109>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com