Expose `sys.stdin` as `None`

Merged
JA
4d ago
+22-4

Summary

Code that checks sys.stdin is None currently raises AttributeError in Monty. Initialize sys.stdin and sys.__stdin__ to None, the value CPython uses when standard input is unavailable. Reads from a closed file raise ValueError. CPython standard streams, CPython I/O

Monty receives data through explicit feed inputs and host functions. In subprocess mode, the worker’s stdin carries framed client requests. The two sys attributes report whether standard input is available to sandboxed Python, independent of how the host runs the worker. Monty host functions, Worker protocol

Tests

  • The import__sys.py regression case fails on Monty before the patch with AttributeError and passes on Monty and CPython after it.

  • All 1,660 fixtures pass with CPython 3.14.10. Type-checker tests, the vendored typeshed check, Rust formatting, and Ruff checks for the touched Python files also pass.

  • I have read the contribution guide.

  • I understand and can explain the proposed changes, including any generated with AI assistance.


Summary by cubic

Exposes sys.stdin and sys.__stdin__ in Monty as None, matching CPython's value when standard input is unavailable. Code checking sys.stdin is None previously raised AttributeError.

  • Updates the sys typeshed stub and adds both attributes to the module.
  • Adds a regression case in import__sys.py and documents the behavior in docs/limitations/sys.md.