From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sun, 28 Dec 2025 17:22:47 +0000 (+0100) Subject: [3.14] gh-142195: Fixed Popen.communicate indefinite loops (GH-143203) (#143255) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8def603d853c7f5e4ff57f95de289f99e1943669;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-142195: Fixed Popen.communicate indefinite loops (GH-143203) (#143255) gh-142195: Fixed Popen.communicate indefinite loops (GH-143203) Changed condition to evaluate if timeout is less than or equals to 0. This is needed for simulated time environments such as Shadow where the time will match exactly on the boundary. --------- (cherry picked from commit fa9a4254e81c0abcc3345021c45aaf5f788f9ea9) Co-authored-by: Prithviraj Chaudhuri Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> --- diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 6911cd8e8597..578d7b95d05d 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -2141,7 +2141,7 @@ class Popen: while selector.get_map(): timeout = self._remaining_time(endtime) - if timeout is not None and timeout < 0: + if timeout is not None and timeout <= 0: self._check_timeout(endtime, orig_timeout, stdout, stderr, skip_check_and_raise=True) diff --git a/Misc/NEWS.d/next/Library/2025-12-27-00-14-56.gh-issue-142195.UgBEo5.rst b/Misc/NEWS.d/next/Library/2025-12-27-00-14-56.gh-issue-142195.UgBEo5.rst new file mode 100644 index 000000000000..b2b1ffe7225b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-12-27-00-14-56.gh-issue-142195.UgBEo5.rst @@ -0,0 +1 @@ +Updated timeout evaluation logic in :mod:`subprocess` to be compatible with deterministic environments like Shadow where time moves exactly as requested.