mirror of
https://github.com/python/cpython.git
synced 2026-10-29 10:55:16 +08:00
A str subclass can override replace() and return a non-string while TextIOWrapper.write() translates newlines. The C implementation then treats the result as Unicode and can crash. Reject an invalid replacement with TypeError. Backport to 3.15 and 3.14; on 3.14, put the regression test in Lib/test/test_io.py.
(cherry picked from commit c6796a1268)