Skip to content

Commit e646cc3

Browse files
[3.13] gh-124917: Allow keyword args to os.path.exists/lexists on Windows (GH-124918) (#125332)
(cherry picked from commit cc2938a)
1 parent 488807a commit e646cc3

File tree

4 files changed

+77
-13
lines changed

4 files changed

+77
-13
lines changed

Lib/test/test_genericpath.py

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

159+
# Keyword arguments are accepted
160+
self.assertIs(self.pathmodule.exists(path=filename), True)
161+
self.assertIs(self.pathmodule.lexists(path=filename), True)
162+
159163
@unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
160164
@unittest.skipIf(is_emscripten, "Emscripten pipe fds have no stat")
161165
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: 69 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5391,15 +5391,14 @@ _testFileType(path_t *path, int testedType)
53915391
os._path_exists -> bool
53925392
53935393
path: path_t(allow_fd=True, suppress_value_error=True)
5394-
/
53955394
53965395
Test whether a path exists. Returns False for broken symbolic links.
53975396
53985397
[clinic start generated code]*/
53995398

54005399
static int
54015400
os__path_exists_impl(PyObject *module, path_t *path)
5402-
/*[clinic end generated code: output=8da13acf666e16ba input=29198507a6082a57]*/
5401+
/*[clinic end generated code: output=8da13acf666e16ba input=142beabfc66783eb]*/
54035402
{
54045403
return _testFileExists(path, TRUE);
54055404
}
@@ -5409,15 +5408,14 @@ os__path_exists_impl(PyObject *module, path_t *path)
54095408
os._path_lexists -> bool
54105409
54115410
path: path_t(allow_fd=True, suppress_value_error=True)
5412-
/
54135411
54145412
Test whether a path exists. Returns True for broken symbolic links.
54155413
54165414
[clinic start generated code]*/
54175415

54185416
static int
54195417
os__path_lexists_impl(PyObject *module, path_t *path)
5420-
/*[clinic end generated code: output=e7240ed5fc45bff3 input=03d9fed8bc6ce96f]*/
5418+
/*[clinic end generated code: output=e7240ed5fc45bff3 input=208205112a3cc1ed]*/
54215419
{
54225420
return _testFileExists(path, FALSE);
54235421
}

0 commit comments

Comments
 (0)