(
lock: UnixFileLock, error: type[BaseException] = KeyboardInterrupt
)
| 18 | |
| 19 | |
| 20 | def interrupt_unix_create( |
| 21 | lock: UnixFileLock, error: type[BaseException] = KeyboardInterrupt |
| 22 | ) -> None: # pragma: needs fcntl |
| 23 | def interrupt( |
| 24 | frame: FrameType, event: str, operation: BuiltinFunctionType | None |
| 25 | ) -> None: # pragma: no cover # profile hooks run with tracing disabled |
| 26 | if ( |
| 27 | event == "c_return" |
| 28 | and frame.f_code.co_name == "open_into" |
| 29 | and (operation is os.open or getattr(operation, "__name__", None) == "extend") |
| 30 | ): |
| 31 | raise error |
| 32 | |
| 33 | previous = sys.getprofile() |
| 34 | sys.setprofile(interrupt) |
| 35 | try: |
| 36 | with pytest.raises(error): |
| 37 | lock.acquire() |
| 38 | finally: |
| 39 | sys.setprofile(previous) |
| 40 | |
| 41 | |
| 42 | @pytest.fixture |
no test coverage detected