[Python-bugs-list] [Bug #112760] python can not read binary file fully

noreply@sourceforge.net noreply@sourceforge.net
Fri, 25 Aug 2000 18:20:15 -0700


Bug #112760, was updated on 2000-Aug-25 17:38
Here is a current snapshot of the bug.

Project: Python
Category: Core
Status: Closed
Resolution: Invalid
Bug Group: None
Priority: 5
Summary: python can not read binary file fully

Details: a binary file (named, say:"mybifile.dat") with length of 26360 (bytes) can not be read fully:
>>>f=open("mybifile.dat")
>>>data=f.read()
>>>len(data)
3325

The reading seems to be interrupted by the binary pattern in the file.

I tried the same with JPython, it works there. I guess it uses java's file-IO.

Jianchi

Follow-Ups:

Date: 2000-Aug-25 18:20
By: effbot

Comment:
http://www.python.org/doc/current/lib/built-in-funcs.html
=> open => "Append 'b' to the mode to open the file in binary mode, on systems that differentiate between binary and text files"

or in other words, change open("mybifile.dat") to open("mybifile.dat", "rb")

(this also falls into the "don't you think someone would have noticed already" category ;-)
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=112760&group_id=5470