# OSError: pytest: error while capturing stdout/stderr

- **ID:** `python/pytest-capture-io-error`
- **Domain:** python
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

pytest在捕获输出时遇到I/O错误，可能因为文件描述符耗尽或输出重定向问题。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (80% success)
   ```
   pytest --capture=sys
   ```
2. **** (90% success)
   ```
   确保所有open()调用都使用with或close()
   ```

## Dead Ends

- **** — 禁用捕获会丢失输出信息，且可能掩盖问题 (70% fail)
- **** — ulimit修改可能不生效或影响系统 (50% fail)
