EOFE
python
io_error
ai_generated
true
EOFError: EOF when reading a line
ID: python/eofeerror-unexpected
90%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 311 | active | — | — | — |
Root Cause
input() called but stdin is closed/empty. Common in Docker, piped input, or automated scripts.
genericWorkarounds
-
92% success Wrap in try/except EOFError for graceful handling
try: line = input() except EOFError: line = ''Sources: https://docs.python.org/3/library/functions.html#input
-
88% success Use sys.stdin with check: for line in sys.stdin:
for line in sys.stdin:
Sources: https://docs.python.org/3/library/sys.html#sys.stdin
Dead Ends
Common approaches that don't work:
-
Add a default value to input()
75% fail
input() doesn't support defaults — need try/except
Error Chain
Frequently confused with: