# RuntimeError: generator didn't stop after throw()

- **ID:** `python/pytest-fixture-yield-without-finally`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

在 fixture 的 yield 之后没有正确处理异常，导致 teardown 代码未执行或生成器未正确关闭。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.10 | active | — | — |

## Workarounds

1. **确保 yield 后没有异常中断** (90% success)
   ```
   @pytest.fixture
def my_fixture():
    setup()
    yield resource
    teardown()
   ```
2. **使用 try/finally 确保清理** (95% success)
   ```
   @pytest.fixture
def my_fixture():
    try:
        yield resource
    finally:
        teardown()
   ```

## Dead Ends

- **yield 后直接写清理代码** — 尝试在 yield 后直接写清理代码，但异常发生时清理代码不执行 (70% fail)
- **在 finally 中再次 yield** — 尝试使用 try/finally 但 finally 中又 yield 导致错误 (50% fail)
