Skip to content

Commit 05dc20f

Browse files
giampaologvanrossum
authored andcommitted
#30624 / selectors: use bare except clause in order to not leave the fd in a bad state in case of error (#2082)
1 parent 6b6e687 commit 05dc20f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Lib/selectors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def modify(self, fileobj, events, data=None):
387387
selector_events |= self._EVENT_WRITE
388388
try:
389389
self._selector.modify(key.fd, selector_events)
390-
except Exception:
390+
except:
391391
super().unregister(fileobj)
392392
raise
393393
changed = True
@@ -524,7 +524,7 @@ def register(self, fileobj, events, data=None):
524524
kev = select.kevent(key.fd, select.KQ_FILTER_WRITE,
525525
select.KQ_EV_ADD)
526526
self._selector.control([kev], 0, 0)
527-
except Exception:
527+
except:
528528
super().unregister(fileobj)
529529
raise
530530
return key

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ Extension Modules
350350
Library
351351
-------
352352

353+
- bpo-30624: selectors does not take KeyboardInterrupt and SystemExit into
354+
account, leaving a fd in a bad state in case of error. Patch by Giampaolo
355+
Rodola'.
356+
353357
- bpo-30595: multiprocessing.Queue.get() with a timeout now polls its reader in
354358
non-blocking mode if it succeeded to aquire the lock but the acquire took
355359
longer than the timeout.

0 commit comments

Comments
 (0)