mirror of
https://github.com/python/cpython.git
synced 2025-11-13 23:46:24 +00:00
gh-109782: Ensure os.path.isdir has the same signature on all platforms (GH-109790)
This commit is contained in:
parent
3814bc1723
commit
7df8b16d28
3 changed files with 15 additions and 13 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
Ensure the signature of :func:`os.path.isdir` is identical on all platforms.
|
||||||
|
Patch by Amin Alaee.
|
||||||
16
Modules/clinic/posixmodule.c.h
generated
16
Modules/clinic/posixmodule.c.h
generated
|
|
@ -1977,7 +1977,7 @@ exit:
|
||||||
#if defined(MS_WINDOWS)
|
#if defined(MS_WINDOWS)
|
||||||
|
|
||||||
PyDoc_STRVAR(os__path_isdir__doc__,
|
PyDoc_STRVAR(os__path_isdir__doc__,
|
||||||
"_path_isdir($module, /, path)\n"
|
"_path_isdir($module, /, s)\n"
|
||||||
"--\n"
|
"--\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Return true if the pathname refers to an existing directory.");
|
"Return true if the pathname refers to an existing directory.");
|
||||||
|
|
@ -1986,7 +1986,7 @@ PyDoc_STRVAR(os__path_isdir__doc__,
|
||||||
{"_path_isdir", _PyCFunction_CAST(os__path_isdir), METH_FASTCALL|METH_KEYWORDS, os__path_isdir__doc__},
|
{"_path_isdir", _PyCFunction_CAST(os__path_isdir), METH_FASTCALL|METH_KEYWORDS, os__path_isdir__doc__},
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
os__path_isdir_impl(PyObject *module, PyObject *path);
|
os__path_isdir_impl(PyObject *module, PyObject *s);
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
os__path_isdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
os__path_isdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
||||||
|
|
@ -2001,7 +2001,7 @@ os__path_isdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje
|
||||||
PyObject *ob_item[NUM_KEYWORDS];
|
PyObject *ob_item[NUM_KEYWORDS];
|
||||||
} _kwtuple = {
|
} _kwtuple = {
|
||||||
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
|
||||||
.ob_item = { &_Py_ID(path), },
|
.ob_item = { &_Py_ID(s), },
|
||||||
};
|
};
|
||||||
#undef NUM_KEYWORDS
|
#undef NUM_KEYWORDS
|
||||||
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
|
||||||
|
|
@ -2010,7 +2010,7 @@ os__path_isdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje
|
||||||
# define KWTUPLE NULL
|
# define KWTUPLE NULL
|
||||||
#endif // !Py_BUILD_CORE
|
#endif // !Py_BUILD_CORE
|
||||||
|
|
||||||
static const char * const _keywords[] = {"path", NULL};
|
static const char * const _keywords[] = {"s", NULL};
|
||||||
static _PyArg_Parser _parser = {
|
static _PyArg_Parser _parser = {
|
||||||
.keywords = _keywords,
|
.keywords = _keywords,
|
||||||
.fname = "_path_isdir",
|
.fname = "_path_isdir",
|
||||||
|
|
@ -2018,14 +2018,14 @@ os__path_isdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje
|
||||||
};
|
};
|
||||||
#undef KWTUPLE
|
#undef KWTUPLE
|
||||||
PyObject *argsbuf[1];
|
PyObject *argsbuf[1];
|
||||||
PyObject *path;
|
PyObject *s;
|
||||||
|
|
||||||
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
|
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
|
||||||
if (!args) {
|
if (!args) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
path = args[0];
|
s = args[0];
|
||||||
return_value = os__path_isdir_impl(module, path);
|
return_value = os__path_isdir_impl(module, s);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
|
|
@ -11988,4 +11988,4 @@ exit:
|
||||||
#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
|
#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
|
||||||
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
|
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
|
||||||
#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
|
#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
|
||||||
/*[clinic end generated code: output=1dd5aa7495cd6e3a input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=51aa26bc6a41e1da input=a9049054013a1b77]*/
|
||||||
|
|
|
||||||
|
|
@ -4912,25 +4912,25 @@ os__path_splitroot_impl(PyObject *module, path_t *path)
|
||||||
/*[clinic input]
|
/*[clinic input]
|
||||||
os._path_isdir
|
os._path_isdir
|
||||||
|
|
||||||
path: 'O'
|
s: 'O'
|
||||||
|
|
||||||
Return true if the pathname refers to an existing directory.
|
Return true if the pathname refers to an existing directory.
|
||||||
|
|
||||||
[clinic start generated code]*/
|
[clinic start generated code]*/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
os__path_isdir_impl(PyObject *module, PyObject *path)
|
os__path_isdir_impl(PyObject *module, PyObject *s)
|
||||||
/*[clinic end generated code: output=00faea0af309669d input=b1d2571cf7291aaf]*/
|
/*[clinic end generated code: output=9d87ab3c8b8a4e61 input=c17f7ef21d22d64e]*/
|
||||||
{
|
{
|
||||||
HANDLE hfile;
|
HANDLE hfile;
|
||||||
BOOL close_file = TRUE;
|
BOOL close_file = TRUE;
|
||||||
FILE_BASIC_INFO info;
|
FILE_BASIC_INFO info;
|
||||||
path_t _path = PATH_T_INITIALIZE("isdir", "path", 0, 1);
|
path_t _path = PATH_T_INITIALIZE("isdir", "s", 0, 1);
|
||||||
int result;
|
int result;
|
||||||
BOOL slow_path = TRUE;
|
BOOL slow_path = TRUE;
|
||||||
FILE_STAT_BASIC_INFORMATION statInfo;
|
FILE_STAT_BASIC_INFORMATION statInfo;
|
||||||
|
|
||||||
if (!path_converter(path, &_path)) {
|
if (!path_converter(s, &_path)) {
|
||||||
path_cleanup(&_path);
|
path_cleanup(&_path);
|
||||||
if (PyErr_ExceptionMatches(PyExc_ValueError)) {
|
if (PyErr_ExceptionMatches(PyExc_ValueError)) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue