Restore PrettyFormat streams after reentrant calls
Merged
MA
2mo ago+56+56+01234567890123456789-2-2-0123456789
Closes #162.
Calling pformat inside an object's __repr__ currently replaces the outer formatter's stream and duplicates output. Save and restore the previous stream in finally so nested formatting and exceptions preserve the caller's output.
Regression tests cover nested repr calls, containers, pprint, and recovery after exceptions. Previously validated test suite with optional dependencies: 120 passed, 4 skipped; the full supported interpreter/platform matrix was not run.
AI assistance was used to implement this change and its automated tests.