diff options
-rw-r--r-- | Lib/pathlib.py | 4 | ||||
-rw-r--r-- | Lib/test/test_pathlib.py | 5 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-04-18-17-45-03.bpo-29847.Uxtbq0.rst | 1 |
3 files changed, 10 insertions, 0 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py index a0678f6..ae7a62f 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -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) diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index 7d4d782..1fe242b 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -2571,6 +2571,11 @@ class _BasePathTest(object): def test_complex_symlinks_relative_dot_dot(self): self._check_complex_symlinks(os.path.join('dirA', '..')) + def test_passing_kwargs_deprecated(self): + with self.assertWarns(DeprecationWarning): + self.cls(foo="bar") + + class WalkTests(unittest.TestCase): def setUp(self): diff --git a/Misc/NEWS.d/next/Library/2020-04-18-17-45-03.bpo-29847.Uxtbq0.rst b/Misc/NEWS.d/next/Library/2020-04-18-17-45-03.bpo-29847.Uxtbq0.rst new file mode 100644 index 0000000..010d775 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-04-18-17-45-03.bpo-29847.Uxtbq0.rst @@ -0,0 +1 @@ +Fix a bug where :class:`pathlib.Path` accepted and ignored keyword arguments. Patch provided by Yurii Karabas. |