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 serhiy.storchaka
Recipients JelleZijlstra, Jim Fasarakis-Hilliard, brett.cannon, pitrou, serhiy.storchaka
Date 2017-03-20.19:15:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490037326.45.0.177191485152.issue29847@psf.upfronthosting.co.za>
In-reply-to
Content
The support of **kwargs in Path.__new__ is needed if you want to implement a subclass of Path with __init__ accepting keyword arguments (and since Path constructor takes variable number of positional arguments, new arguments should be keyword-only).

>>> import pathlib
>>> class MyPath(pathlib.PosixPath):
...     def __init__(self, *args, spam=False):
...         self.spam = spam
... 
>>> p = MyPath('/', spam=True)
>>> p
MyPath('/')
>>> p.spam
True

Removing **kwargs from Path.__new__ will break the above example.

>>> MyPath('/', spam=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __new__() got an unexpected keyword argument 'spam'
History
Date User Action Args
2017-03-20 19:15:26serhiy.storchakasetrecipients: + serhiy.storchaka, brett.cannon, pitrou, JelleZijlstra, Jim Fasarakis-Hilliard
2017-03-20 19:15:26serhiy.storchakasetmessageid: <1490037326.45.0.177191485152.issue29847@psf.upfronthosting.co.za>
2017-03-20 19:15:26serhiy.storchakalinkissue29847 messages
2017-03-20 19:15:26serhiy.storchakacreate