Thank you @ncoghlan for the information! I did not know that this problem has been brought into your attention so long ago…
Is there any ongoing attempt/proposal to have “atomic” code blocks which can be free of async exceptions just like C-bindings?
Something like this:
And this:
class Wrapper:
atomic def __exit__(self, *_):
# KeyboardInterrupt here will be deferred
# until execution exits the function
self.cleanup()
Since deferring async exceptions is a breaking change that changes when interrupts are raised, I guess this has to be explicitly requested (hence a new keyword).