Skip to content

Commit cf884bd

Browse files
committed
[3.12] pythongh-124917: Allow keyword args to os.path.exists/lexists on Windows (pythonGH-124918)
(cherry picked from commit cc2938a) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 5903631 commit cf884bd

4 files changed

Lines changed: 42 additions & 7 deletions

File tree

Lib/test/test_genericpath.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ def test_exists(self):
158158
self.assertIs(self.pathmodule.lexists(filename + '\x00'), False)
159159
self.assertIs(self.pathmodule.lexists(bfilename + b'\x00'), False)
160160

161+
# Keyword arguments are accepted
162+
self.assertIs(self.pathmodule.exists(path=filename), True)
163+
self.assertIs(self.pathmodule.lexists(path=filename), True)
164+
161165
@unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
162166
@unittest.skipIf(is_emscripten, "Emscripten pipe fds have no stat")
163167
def test_exists_fd(self):
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Allow calling :func:`os.path.exists` and :func:`os.path.lexists` with
2+
keyword arguments on Windows. Fixes a regression in 3.13.0.

Modules/clinic/posixmodule.c.h

Lines changed: 35 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5209,15 +5209,14 @@ _testFileType(path_t *path, int testedType)
52095209
os._path_exists -> bool
52105210
52115211
path: path_t(allow_fd=True, suppress_value_error=True)
5212-
/
52135212
52145213
Test whether a path exists. Returns False for broken symbolic links.
52155214
52165215
[clinic start generated code]*/
52175216

52185217
static int
52195218
os__path_exists_impl(PyObject *module, path_t *path)
5220-
/*[clinic end generated code: output=8da13acf666e16ba input=29198507a6082a57]*/
5219+
/*[clinic end generated code: output=8da13acf666e16ba input=142beabfc66783eb]*/
52215220
{
52225221
return _testFileExists(path, TRUE);
52235222
}

0 commit comments

Comments
 (0)