8000 GH-74033: Drop deprecated `pathlib.Path` keyword arguments by barneygale · Pull Request #118793 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-74033: Drop deprecated pathlib.Path keyword arguments #118793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
GH-74033: Drop deprecated pathlib.Path() keyword arguments
Remove support for supplying keyword arguments to `pathlib.Path()`. This
has been deprecated since Python 3.12.
  • Loading branch information
barneygale committed May 8, 2024
commit 2468f332ba4df9fa50597c43da6480100ae334a0
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ Deprecated
Removed
=======

pathlib
-------

* Remove support for passing additional keyword arguments to
:class:`pathlib.Path`. In previous versions, any such arguments are ignored.


Porting to Python 3.14
Expand Down
9 changes: 1 addition & 8 deletions Lib/pathlib/_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import os
import posixpath
import sys
import warnings
from glob import _StringGlobber
from itertools import chain
from _collections_abc import Sequence
Expand Down Expand Up @@ -417,6 +416,7 @@ def is_absolute(self):
def is_reserved(self):
"""Return True if the path contains one of the special names reserved
by the system, if any."""
import warnings
msg = ("pathlib.PurePath.is_reserved() is deprecated and scheduled "
"for removal in Python 3.15. Use os.path.isreserved() to "
"detect reserved paths on Windows.")
Expand Down Expand Up @@ -495,13 +495,6 @@ class Path(PathBase, PurePath):
def _unsupported_msg(cls, attribute):
return f"{cls.__name__}.{attribute} is unsupported on this system"

def __init__(self, *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))
super().__init__(*args)

def __new__(cls, *args, **kwargs):
if cls is Path:
cls = WindowsPath if os.name == 'nt' else PosixPath
Expand Down
4 changes: 0 additions & 4 deletions Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,6 @@ def test_is_mount_root(self):
self.assertTrue(R.is_mount())
self.assertFalse((R / '\udfff').is_mount())

def test_passing_kwargs_deprecated(self):
with self.assertWarns(DeprecationWarning):
self.cls(foo="bar")

def setUpWalk(self):
super().setUpWalk()
sub21_path= self.sub2_path / "SUB21"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop support for passing keyword arguments to :class:`pathlib.Path`.
0