Closed
Description
Bug report
Bug description:
I mentioned regex but this probably applies to other modules as well. In the code below, if the #
line right after the findall is commented out (as it is right now), the code raises the exception past the try-except block on the print("Safely reached EOF.")
statement. The exception happens one statement later than expected. NB: I tested all Python versions on Windows but only 3.11 on Linux.
import _thread, re from threading import Timer s = "ab"*20000000 pattern = re.compile("ab+") Timer(0.2, _thread.interrupt_main).start() try: pattern.findall(s) # print() ################################################################### except: print("Exception block") print("Safely reached EOF.")
CPython versions tested on:
3.9, 3.10, 3.11, 3.12, CPython main branch
Operating systems tested on:
Linux, Windows