This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: file.read returns reaches EOF when it shouldn't
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, rhettinger, tim.peters, turingcomplete
Priority: normal Keywords:

Created on 2004-01-11 22:37 by turingcomplete, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg19628 - (view) Author: Joshua Allen (turingcomplete) Date: 2004-01-11 22:37
If the first byte of a file is 0xFF file.read(size)
will return an empty string.  Problem found while
trying to process binary file produced by another system.
msg19629 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-01-11 22:50
Logged In: YES 
user_id=80475

I tried it an Py2.2.3, Py2.3.3, and Py2.4a0 and it works
fine.  Perhaps you have some other problem.

>>> f = open('/pydev/hello.bin', 'rb')
>>> f.read(6)
'\xffhello'

The docstring for file.read does warn that sometimes fewer
bytes than requested can be returned in a non-blocking mode.
msg19630 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-01-11 23:57
Logged In: YES 
user_id=31435

turingcomplete, please say which version of Python you're 
using, which operating system, and show the actual code you 
use to open the file and read from it.  Else this one is just too 
hard to believe -- if there were a general problem like this, it 
would have been reported many times.
msg19631 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-06-01 12:17
Logged In: YES 
user_id=1188172

I think this can be closed due to lack of response.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39803
2004-01-11 22:37:02turingcompletecreate