https://github.com/python/cpython/commit/3e2cceaa871a742a66711519d8e6998b186ae263
commit: 3e2cceaa871a742a66711519d8e6998b186ae263
branch: main
author: Irit Katriel <[email protected]>
committer: iritkatriel <[email protected]>
date: 2025-03-21T18:05:47Z
summary:
gh-131233: remove return-in-finally in multiprocessing/connection.py (#131416)
files:
M Lib/multiprocessing/connection.py
diff --git a/Lib/multiprocessing/connection.py
b/Lib/multiprocessing/connection.py
index d429212d447380..5f288a8d393240 100644
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -322,22 +322,32 @@ def _recv_bytes(self, maxsize=None):
try:
ov, err = _winapi.ReadFile(self._handle, bsize,
overlapped=True)
+
+ sentinel = object()
+ return_value = sentinel
try:
- if err == _winapi.ERROR_IO_PENDING:
- waitres = _winapi.WaitForMultipleObjects(
- [ov.event], False, INFINITE)
- assert waitres == WAIT_OBJECT_0
+ try:
+ if err == _winapi.ERROR_IO_PENDING:
+ waitres = _winapi.WaitForMultipleObjects(
+ [ov.event], False, INFINITE)
+ assert waitres == WAIT_OBJECT_0
+ except:
+ ov.cancel()
+ raise
+ finally:
+ nread, err = ov.GetOverlappedResult(True)
+ if err == 0:
+ f = io.BytesIO()
+ f.write(ov.getbuffer())
+ return_value = f
+ elif err == _winapi.ERROR_MORE_DATA:
+ return_value = self._get_more_data(ov, maxsize)
except:
- ov.cancel()
- raise
- finally:
- nread, err = ov.GetOverlappedResult(True)
- if err == 0:
- f = io.BytesIO()
- f.write(ov.getbuffer())
- return f
- elif err == _winapi.ERROR_MORE_DATA:
- return self._get_more_data(ov, maxsize)
+ if return_value is sentinel:
+ raise
+
+ if return_value is not sentinel:
+ return return_value
except OSError as e:
if e.winerror == _winapi.ERROR_BROKEN_PIPE:
raise EOFError
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]