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 projetmbc
Recipients projetmbc
Date 2015-05-06.05:26:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1430890013.04.0.304568332905.issue24132@psf.upfronthosting.co.za>
In-reply-to
Content
Hello.

I have noticed a problem with the following code.

from pathlib import Path

class PPath(Path):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

test = PPath("dir", "test.txt")

This gives the following error message.

 
Traceback (most recent call last):
  File "/Users/projetmbc/test.py", line 14, in <module>
    test = PPath("dir", "test.txt")
  File "/anaconda/lib/python3.4/pathlib.py", line 907, in __new__
    self = cls._from_parts(args, init=False)
  File "/anaconda/lib/python3.4/pathlib.py", line 589, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/anaconda/lib/python3.4/pathlib.py", line 582, in _parse_args
    return cls._flavour.parse_parts(parts)
AttributeError: type object 'PPath' has no attribute '_flavour'

This breaks the sub-classing from Python point of view.

There is an ugly hack to sub-class Path but it's a bit unpythonic.
History
Date User Action Args
2015-05-06 05:26:53projetmbcsetrecipients: + projetmbc
2015-05-06 05:26:53projetmbcsetmessageid: <1430890013.04.0.304568332905.issue24132@psf.upfronthosting.co.za>
2015-05-06 05:26:52projetmbclinkissue24132 messages
2015-05-06 05:26:52projetmbccreate