Honour `open()`'s `newline` argument and make file objects iterable
In preparation for csv support.
open() accepts all five newline values with CPython's splitting and translation: None translates \r\n/\r to \n once when the buffer is installed, '' keeps terminators, and '\r'/'\r\n' also translate \n on write while write() reports the length as passed. Binary mode rejects the argument up front; an illegal value raises after the open, as CPython does.
Files are their own iterators: iter(f) is f and __next__ is one readline() from the heap buffer. An unread file is loaded lazily on the first step. ForIter yields the read with a BufferLoad effect and rewinds the instruction pointer so it re-dispatches against the buffer; next() yields with a FileNext effect that owns the default across the yield and answers the call. Consumers that cannot suspend (list(f), enumerate(f), …) raise NotImplementedError until a read or seek() has loaded the buffer, which limitations/open.md records.
Claude-Session: https://claude.ai/code/session_014YiTTzCM85EAg9yP4XQCUC
Summary by cubic
Honours open()'s newline argument with all five values and makes file objects iterable, matching CPython's line splitting, translation, and error behavior.
newline=Nonetranslates\r\n/\rto\nwhen the buffer loads;''keeps terminators;'\r'/'\r\n'also translate\non write whilewrite()reports the length as passed. Binary mode rejects the argument up front; an illegal value raises after the open, as CPython does.iter(f) is fand each__next__step is onereadline()from the heap buffer. An unread file loads lazily on the firstforstep ornext()call; other consumers (list(f),enumerate(f), …) raiseNotImplementedErroruntil a read orseek()has loaded it, now documented indocs/limitations/open.md.- A future reply to the load that
forornext()waits on raisesRuntimeError: file iteration cannot be answered with a future; generator expressions compile toforloops and can load an unread file. The remaining Rust-side consumers will later get a call-boundary retry instead of raising.