gh-74033: Fix bug when Path takes and ignores **kwargs (GH-19632)

Fix a bug where `Path` takes and ignores `**kwargs` by adding to `PurePath`  class `__init__` method which can take only positional arguments.

Automerge-Triggered-By: GH:brettcannon
This commit is contained in:
Yurii Karabas 2023-01-14 02:05:43 +02:00 committed by GitHub
parent 1bc7a73683
commit 080cb27829
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View file

@ -713,6 +713,10 @@ class Path(PurePath):
__slots__ = ()
def __new__(cls, *args, **kwargs):
if kwargs:
msg = ("support for supplying keyword arguments to pathlib.PurePath "
"is deprecated and scheduled for removal in Python {remove}")
warnings._deprecated("pathlib.PurePath(**kwargs)", msg, remove=(3, 14))
if cls is Path:
cls = WindowsPath if os.name == 'nt' else PosixPath
self = cls._from_parts(args)