gh-128067: Fix pyrepl overriding printed output without newlines (#138732) Co-authored-by: Ćukasz Langa <lukasz@langa.pl>