| 2163 | |
| 2164 | @contextlib.contextmanager |
| 2165 | def disable_faulthandler(): |
| 2166 | import faulthandler |
| 2167 | |
| 2168 | # use sys.__stderr__ instead of sys.stderr, since regrtest replaces |
| 2169 | # sys.stderr with a StringIO which has no file descriptor when a test |
| 2170 | # is run with -W/--verbose3. |
| 2171 | fd = sys.__stderr__.fileno() |
| 2172 | |
| 2173 | is_enabled = faulthandler.is_enabled() |
| 2174 | try: |
| 2175 | faulthandler.disable() |
| 2176 | yield |
| 2177 | finally: |
| 2178 | if is_enabled: |
| 2179 | faulthandler.enable(file=fd, all_threads=True) |
| 2180 | |
| 2181 | |
| 2182 | class SaveSignals: |