bpo-31158: Fix nondeterministic read in test_pty (#3808) (#3853)

(cherry picked from commit e6f62f69f07892b993910ff03c9db3ffa5cb9ca5)
1 file changed