gh-133089: Use original timeout value for TimeoutExpired when the func subprocess.run is called with a timeout (GH-133103)

Signed-off-by: Manjusaka <me@manjusaka.me>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
Nadeshiko Manju 2025-05-05 09:15:31 +08:00 committed by GitHub
parent 51d2459e4d
commit 2bbcaedb75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 4 deletions

View file

@ -1235,8 +1235,11 @@ class Popen:
finally:
self._communication_started = True
sts = self.wait(timeout=self._remaining_time(endtime))
try:
sts = self.wait(timeout=self._remaining_time(endtime))
except TimeoutExpired as exc:
exc.timeout = timeout
raise
return (stdout, stderr)
@ -2145,8 +2148,11 @@ class Popen:
selector.unregister(key.fileobj)
key.fileobj.close()
self._fileobj2output[key.fileobj].append(data)
self.wait(timeout=self._remaining_time(endtime))
try:
self.wait(timeout=self._remaining_time(endtime))
except TimeoutExpired as exc:
exc.timeout = orig_timeout
raise
# All data exchanged. Translate lists into strings.
if stdout is not None: