https://github.com/python/cpython/commit/c9932a9ec8a3077933a85101aae9c3ac155e6d04
commit: c9932a9ec8a3077933a85101aae9c3ac155e6d04
branch: main
author: Barney Gale <barney.g...@gmail.com>
committer: barneygale <barney.g...@gmail.com>
date: 2025-03-01T21:25:38Z
summary:

GH-127381: pathlib ABCs: remove `WritablePath.mkdir()` arguments (#130611)

Remove the *mode*, *parents* and *exist_ok* arguments from
`WritablePath.mkdir()`. These arguments imply support for POSIX permissions
and checking for preexistence of the path or its parents, but subclasses of
`WritablePath` may not have these capabilities.

The public `Path.mkdir()` method retains these arguments.

files:
M Lib/pathlib/_abc.py
M Lib/test/test_pathlib/test_pathlib_abc.py

diff --git a/Lib/pathlib/_abc.py b/Lib/pathlib/_abc.py
index cb5af3230bfd67..d9fb018d75f538 100644
--- a/Lib/pathlib/_abc.py
+++ b/Lib/pathlib/_abc.py
@@ -352,7 +352,7 @@ def symlink_to(self, target, target_is_directory=False):
         raise NotImplementedError
 
     @abstractmethod
-    def mkdir(self, mode=0o777, parents=False, exist_ok=False):
+    def mkdir(self):
         """
         Create a new directory at this given path.
         """
diff --git a/Lib/test/test_pathlib/test_pathlib_abc.py 
b/Lib/test/test_pathlib/test_pathlib_abc.py
index efc6c17962e261..1c1797ff04f653 100644
--- a/Lib/test/test_pathlib/test_pathlib_abc.py
+++ b/Lib/test/test_pathlib/test_pathlib_abc.py
@@ -914,23 +914,17 @@ def __open_wb__(self, buffering=-1):
         self._directories[parent].add(name)
         return DummyWritablePathIO(self._files, path)
 
-    def mkdir(self, mode=0o777, parents=False, exist_ok=False):
+    def mkdir(self):
         path = str(self)
         parent = str(self.parent)
         if path in self._directories:
-            if exist_ok:
-                return
-            else:
-                raise FileExistsError(errno.EEXIST, "File exists", path)
+            raise FileExistsError(errno.EEXIST, "File exists", path)
         try:
             if self.name:
                 self._directories[parent].add(self.name)
             self._directories[path] = set()
         except KeyError:
-            if not parents:
-                raise FileNotFoundError(errno.ENOENT, "File not found", 
parent) from None
-            self.parent.mkdir(parents=True, exist_ok=True)
-            self.mkdir(mode, parents=False, exist_ok=exist_ok)
+            raise FileNotFoundError(errno.ENOENT, "File not found", parent) 
from None
 
     def symlink_to(self, target, target_is_directory=False):
         raise NotImplementedError

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to