@@ -1280,6 +1280,8 @@ get_posix_state(PyObject *module)
12801280 * Contains a file descriptor if path.accept_fd was true
12811281 * and the caller provided a signed integer instead of any
12821282 * sort of string.
1283+ * path.is_fd
1284+ * True if path was provided as a file descriptor.
12831285 *
12841286 * WARNING: if your "path" parameter is optional, and is
12851287 * unspecified, path_converter will never get called.
@@ -1332,6 +1334,7 @@ typedef struct {
13321334 const wchar_t *wide;
13331335 const char *narrow;
13341336 int fd;
1337+ bool is_fd;
13351338 int value_error;
13361339 Py_ssize_t length;
13371340 PyObject *object;
@@ -1341,7 +1344,7 @@ typedef struct {
13411344#define PATH_T_INITIALIZE(function_name, argument_name, nullable, nonstrict, \
13421345 make_wide, suppress_value_error, allow_fd) \
13431346 {function_name, argument_name, nullable, nonstrict, make_wide, \
1344- suppress_value_error, allow_fd, NULL, NULL, -1, 0, 0, NULL, NULL}
1347+ suppress_value_error, allow_fd, NULL, NULL, -1, false, 0, 0, NULL, NULL}
13451348#ifdef MS_WINDOWS
13461349#define PATH_T_INITIALIZE_P(function_name, argument_name, nullable, \
13471350 nonstrict, suppress_value_error, allow_fd) \
@@ -1475,6 +1478,7 @@ path_converter(PyObject *o, void *p)
14751478 }
14761479 path->wide = NULL;
14771480 path->narrow = NULL;
1481+ path->is_fd = true;
14781482 goto success_exit;
14791483 }
14801484 else {
@@ -14328,8 +14332,9 @@ os_pathconf_impl(PyObject *module, path_t *path, int name)
1432814332
1432914333 errno = 0;
1433014334#ifdef HAVE_FPATHCONF
14331- if (path->fd != -1)
14335+ if (path->is_fd) {
1433214336 limit = fpathconf(path->fd, name);
14337+ }
1433314338 else
1433414339#endif
1433514340 limit = pathconf(path->narrow, name);
0 commit comments