This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Jeffrey.Kintscher
Recipients Jeffrey.Kintscher, conchylicultor, pitrou
Date 2020-08-08.01:36:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1596850563.09.0.385831243835.issue41109@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-08-08 01:36:03Jeffrey.Kintschersetrecipients: + Jeffrey.Kintscher, pitrou, conchylicultor
2020-08-08 01:36:03Jeffrey.Kintschersetmessageid: <1596850563.09.0.385831243835.issue41109@roundup.psfhosted.org>
2020-08-08 01:36:03Jeffrey.Kintscherlinkissue41109 messages
2020-08-08 01:36:02Jeffrey.Kintschercreate