From d3398f2f5741fd288ca6314e9697c5af84114d90 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Mon, 13 Dec 2021 23:28:52 +0900 Subject: [PATCH 1/2] bpo-45919: Remove out of date comment --- Python/pylifecycle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index a9eb38775c42ac..7980dc1d99424c 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -2173,8 +2173,8 @@ is_valid_fd(int fd) side of the pipe is closed, dup(1) succeed, whereas fstat(1, &st) fails with EBADF. FreeBSD has similar issue (bpo-32849). - Only use dup() on platforms where dup() is enough to detect invalid FD in - corner cases: on Linux and Windows (bpo-32849). + Only use dup() on Linux where dup() is enough to detect invalid FD + (bpo-32849). */ if (fd < 0) { return 0; From 76909d1171915bc68fdb72bc56de75d93e9e14e1 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Tue, 14 Dec 2021 10:02:54 +0900 Subject: [PATCH 2/2] bpo-45919: Address Victor's review --- Python/pylifecycle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 7980dc1d99424c..c890b7298d7610 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -2168,6 +2168,8 @@ is_valid_fd(int fd) some platforms. fcntl(fd, F_GETFD) is even faster, because it only checks the process table. + It is preferred over dup() when available, since it cannot fail with the + "too many open files" error (EMFILE). bpo-30225: On macOS Tiger, when stdout is redirected to a pipe and the other side of the pipe is closed, dup(1) succeed, whereas fstat(1, &st) fails with