[issue5505] sys.stdin.read() doesn't return after first EOF on Windows

Hirokazu Yamamoto report at bugs.python.org
Wed Mar 18 17:55:23 CET 2009


Hirokazu Yamamoto <ocean-city at m2.ccsnet.ne.jp> added the comment:

With following patch for investigation, (release30-maint)

Index: Lib/io.py
===================================================================
--- Lib/io.py	(revision 70450)
+++ Lib/io.py	(working copy)
@@ -57,6 +57,7 @@
 
 import os
 import abc
+import sys
 import codecs
 import _fileio
 # Import _thread instead of threading to reduce startup cost
@@ -931,6 +932,7 @@
             while True:
                 # Read until EOF or until read() would block.
                 chunk = self.raw.read()
+                print("============>", repr(chunk), file=sys.stderr)
                 if chunk in empty_values:
                     nodata_val = chunk
                     break

///////////////////////

I got this result.

>>> sys.stdin.read()
abc
^Z
============> b'abc\n'
^Z
============> b''
'abc\n'

To get empty chunk, we need to hit CTRL-Z twice.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5505>
_______________________________________


More information about the Python-bugs-list mailing list